mirror of
https://github.com/jazzband/django-downloadview.git
synced 2026-03-16 22:40:25 +00:00
Fix test.
This commit is contained in:
parent
bd41e6f7bf
commit
6cd9ec3dd0
6 changed files with 94 additions and 93 deletions
|
|
@ -44,7 +44,8 @@ class StaticPathTestCase(django.test.TestCase):
|
|||
url = reverse("storage:static_path", kwargs={"path": "1.txt"})
|
||||
year = datetime.date.today().year + 4
|
||||
response = self.client.get(
|
||||
url, HTTP_IF_MODIFIED_SINCE=f"Sat, 29 Oct {year} 19:43:31 GMT",
|
||||
url,
|
||||
HTTP_IF_MODIFIED_SINCE=f"Sat, 29 Oct {year} 19:43:31 GMT",
|
||||
)
|
||||
self.assertTrue(isinstance(response, HttpResponseNotModified))
|
||||
|
||||
|
|
|
|||
|
|
@ -125,11 +125,13 @@ class DownloadResponseValidator(object):
|
|||
check_ascii = True
|
||||
if check_ascii:
|
||||
test_case.assertIn(
|
||||
f'filename="{ascii_name}"', response["Content-Disposition"],
|
||||
f'filename="{ascii_name}"',
|
||||
response["Content-Disposition"],
|
||||
)
|
||||
if check_utf8:
|
||||
test_case.assertIn(
|
||||
f"filename*=UTF-8''{utf8_name}", response["Content-Disposition"],
|
||||
f"filename*=UTF-8''{utf8_name}",
|
||||
response["Content-Disposition"],
|
||||
)
|
||||
|
||||
def assert_content_type(self, test_case, response, value):
|
||||
|
|
|
|||
95
docs/conf.py
95
docs/conf.py
|
|
@ -3,12 +3,10 @@
|
|||
import os
|
||||
import re
|
||||
|
||||
|
||||
# Minimal Django settings. Required to use sphinx.ext.autodoc, because
|
||||
# django-downloadview depends on Django...
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
settings.configure(
|
||||
DATABASES={}, # Required to load ``django.views.generic``.
|
||||
)
|
||||
|
|
@ -18,63 +16,61 @@ settings.configure(
|
|||
|
||||
# Extensions.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.autosummary',
|
||||
'sphinx.ext.doctest',
|
||||
'sphinx.ext.coverage',
|
||||
'sphinx.ext.intersphinx',
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.autosummary",
|
||||
"sphinx.ext.doctest",
|
||||
"sphinx.ext.coverage",
|
||||
"sphinx.ext.intersphinx",
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.txt'
|
||||
source_suffix = ".txt"
|
||||
|
||||
# The encoding of source files.
|
||||
source_encoding = 'utf-8'
|
||||
source_encoding = "utf-8"
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = u'django-downloadview'
|
||||
project_slug = re.sub(r'([\w_.-]+)', u'-', project)
|
||||
copyright = u'2012-2015, Benoît Bryon'
|
||||
author = u'Benoît Bryon'
|
||||
author_slug = re.sub(r'([\w_.-]+)', u'-', author)
|
||||
project = u"django-downloadview"
|
||||
project_slug = re.sub(r"([\w_.-]+)", u"-", project)
|
||||
copyright = u"2012-2015, Benoît Bryon"
|
||||
author = u"Benoît Bryon"
|
||||
author_slug = re.sub(r"([\w_.-]+)", u"-", author)
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
configuration_dir = os.path.dirname(__file__)
|
||||
documentation_dir = configuration_dir
|
||||
version_file = os.path.normpath(os.path.join(
|
||||
documentation_dir,
|
||||
'../VERSION'))
|
||||
version_file = os.path.normpath(os.path.join(documentation_dir, "../VERSION"))
|
||||
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = open(version_file).read().strip()
|
||||
# The short X.Y version.
|
||||
version = '.'.join(release.split('.')[0:1])
|
||||
version = ".".join(release.split(".")[0:1])
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
language = 'en'
|
||||
language = "en"
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
|
||||
# -- Options for HTML output --------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'alabaster'
|
||||
html_theme = "alabaster"
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
|
|
@ -83,23 +79,22 @@ html_static_path = []
|
|||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
html_sidebars = {
|
||||
'**': ['globaltoc.html',
|
||||
'relations.html',
|
||||
'sourcelink.html',
|
||||
'searchbox.html'],
|
||||
"**": ["globaltoc.html", "relations.html", "sourcelink.html", "searchbox.html"],
|
||||
}
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = u'{project}doc'.format(project=project_slug)
|
||||
htmlhelp_basename = u"{project}doc".format(project=project_slug)
|
||||
|
||||
|
||||
# -- Options for sphinx.ext.intersphinx ---------------------------------------
|
||||
|
||||
intersphinx_mapping = {
|
||||
'python': ('http://docs.python.org/2.7', None),
|
||||
'django': ('http://docs.djangoproject.com/en/1.8/',
|
||||
'http://docs.djangoproject.com/en/1.8/_objects/'),
|
||||
'requests': ('http://docs.python-requests.org/en/latest/', None),
|
||||
"python": ("https://docs.python.org/2.7", None),
|
||||
"django": (
|
||||
"https://docs.djangoproject.com/en/1.8/",
|
||||
"https://docs.djangoproject.com/en/1.8/_objects/",
|
||||
),
|
||||
"requests": ("https://requests.readthedocs.io/en/master/", None),
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -111,11 +106,13 @@ latex_elements = {}
|
|||
# (source start file, target name, title, author, documentclass
|
||||
# [howto/manual]).
|
||||
latex_documents = [
|
||||
('index',
|
||||
u'{project}.tex'.format(project=project_slug),
|
||||
u'{project} Documentation'.format(project=project),
|
||||
author,
|
||||
'manual'),
|
||||
(
|
||||
"index",
|
||||
u"{project}.tex".format(project=project_slug),
|
||||
u"{project} Documentation".format(project=project),
|
||||
author,
|
||||
"manual",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -124,11 +121,7 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index',
|
||||
project,
|
||||
u'{project} Documentation'.format(project=project),
|
||||
[author],
|
||||
1)
|
||||
("index", project, u"{project} Documentation".format(project=project), [author], 1)
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -138,11 +131,13 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index',
|
||||
project_slug,
|
||||
u'{project} Documentation'.format(project=project),
|
||||
author,
|
||||
project,
|
||||
'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
project_slug,
|
||||
u"{project} Documentation".format(project=project),
|
||||
author,
|
||||
project,
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
|
|
|||
75
setup.py
75
setup.py
|
|
@ -9,6 +9,7 @@ from setuptools.command.test import test as TestCommand
|
|||
|
||||
class Tox(TestCommand):
|
||||
"""Test command that runs tox."""
|
||||
|
||||
def finalize_options(self):
|
||||
TestCommand.finalize_options(self)
|
||||
self.test_args = []
|
||||
|
|
@ -25,59 +26,61 @@ class Tox(TestCommand):
|
|||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
NAME = 'django-downloadview'
|
||||
DESCRIPTION = 'Serve files with Django and reverse-proxies.'
|
||||
README = open(os.path.join(here, 'README.rst')).read()
|
||||
VERSION = open(os.path.join(here, 'VERSION')).read().strip()
|
||||
AUTHOR = u'Benoît Bryon'
|
||||
EMAIL = 'benoit@marmelune.net'
|
||||
LICENSE = 'BSD'
|
||||
URL = 'https://{name}.readthedocs.io/'.format(name=NAME)
|
||||
NAME = "django-downloadview"
|
||||
DESCRIPTION = "Serve files with Django and reverse-proxies."
|
||||
README = open(os.path.join(here, "README.rst")).read()
|
||||
VERSION = open(os.path.join(here, "VERSION")).read().strip()
|
||||
AUTHOR = u"Benoît Bryon"
|
||||
EMAIL = "benoit@marmelune.net"
|
||||
LICENSE = "BSD"
|
||||
URL = "https://{name}.readthedocs.io/".format(name=NAME)
|
||||
CLASSIFIERS = [
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Framework :: Django',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Programming Language :: Python :: 3 :: Only',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Framework :: Django",
|
||||
"License :: OSI Approved :: BSD License",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
]
|
||||
KEYWORDS = ['file',
|
||||
'stream',
|
||||
'download',
|
||||
'FileField',
|
||||
'ImageField',
|
||||
'x-accel',
|
||||
'x-accel-redirect',
|
||||
'x-sendfile',
|
||||
'sendfile',
|
||||
'mod_xsendfile',
|
||||
'offload']
|
||||
PACKAGES = [NAME.replace('-', '_')]
|
||||
KEYWORDS = [
|
||||
"file",
|
||||
"stream",
|
||||
"download",
|
||||
"FileField",
|
||||
"ImageField",
|
||||
"x-accel",
|
||||
"x-accel-redirect",
|
||||
"x-sendfile",
|
||||
"sendfile",
|
||||
"mod_xsendfile",
|
||||
"offload",
|
||||
]
|
||||
PACKAGES = [NAME.replace("-", "_")]
|
||||
REQUIREMENTS = [
|
||||
# BEGIN requirements
|
||||
'Django>=1.11',
|
||||
'requests',
|
||||
'setuptools',
|
||||
"Django>=1.11",
|
||||
"requests",
|
||||
"setuptools",
|
||||
# END requirements
|
||||
]
|
||||
ENTRY_POINTS = {}
|
||||
SETUP_REQUIREMENTS = ['setuptools']
|
||||
TEST_REQUIREMENTS = ['tox']
|
||||
CMDCLASS = {'test': Tox}
|
||||
SETUP_REQUIREMENTS = ["setuptools"]
|
||||
TEST_REQUIREMENTS = ["tox"]
|
||||
CMDCLASS = {"test": Tox}
|
||||
EXTRA_REQUIREMENTS = {
|
||||
'test': TEST_REQUIREMENTS,
|
||||
"test": TEST_REQUIREMENTS,
|
||||
}
|
||||
|
||||
|
||||
if __name__ == '__main__': # Don't run setup() when we import this module.
|
||||
if __name__ == "__main__": # Don't run setup() when we import this module.
|
||||
setup(
|
||||
name=NAME,
|
||||
version=VERSION,
|
||||
description=DESCRIPTION,
|
||||
long_description=README,
|
||||
classifiers=CLASSIFIERS,
|
||||
keywords=' '.join(KEYWORDS),
|
||||
keywords=" ".join(KEYWORDS),
|
||||
author=AUTHOR,
|
||||
author_email=EMAIL,
|
||||
url=URL,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ class DownloadResponseTestCase(unittest.TestCase):
|
|||
def test_content_disposition_encoding(self):
|
||||
"""Content-Disposition header is encoded."""
|
||||
response = DownloadResponse(
|
||||
"fake file", attachment=True, basename="espacé .txt",
|
||||
"fake file",
|
||||
attachment=True,
|
||||
basename="espacé .txt",
|
||||
)
|
||||
headers = response.default_headers
|
||||
self.assertIn('filename="espace_.txt"', headers["Content-Disposition"])
|
||||
|
|
|
|||
|
|
@ -303,9 +303,7 @@ class VirtualDownloadViewTestCase(unittest.TestCase):
|
|||
:py:class:`django_downloadview.views.VirtualDownloadView`."""
|
||||
|
||||
def test_was_modified_since_specific(self):
|
||||
"""VirtualDownloadView.was_modified_since() delegates to file wrapper.
|
||||
|
||||
"""
|
||||
"""VirtualDownloadView.was_modified_since() delegates to file wrapper."""
|
||||
file_wrapper = mock.Mock()
|
||||
file_wrapper.was_modified_since = mock.Mock(
|
||||
return_value=mock.sentinel.from_file_wrapper
|
||||
|
|
|
|||
Loading…
Reference in a new issue