summaryrefslogtreecommitdiff
path: root/tests/file_uploads
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2014-01-14 15:43:27 +0000
committerMarc Tamlyn <marc.tamlyn@gmail.com>2014-01-14 15:43:27 +0000
commit2607fa901699916c4825f145fa8a84f49b8524ff (patch)
treee211144ca488e24b1b00deda973b5f6bea482843 /tests/file_uploads
parentac8d0a48157c4a53f971cf2450cb6c8ee6c05f36 (diff)
Fixed #21774 -- Isolate all test urls from eachother.
This (nearly) completes the work to isolate all the test modules from each other. This is now more important as importing models from another module will case PendingDeprecationWarnings if those modules are not in INSTALLED_APPS. The only remaining obvious dependencies are: - d.c.auth depends on d.c.admin (because of the is_admin flag to some views), but this is not so important and d.c.admin is in always_installed_apps - test_client_regress depends on test_client. Eventually these should become a single module, as the split serves no useful purpose.
Diffstat (limited to 'tests/file_uploads')
-rw-r--r--tests/file_uploads/tests.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py
index f4e4ea31b2..e86883fc25 100644
--- a/tests/file_uploads/tests.py
+++ b/tests/file_uploads/tests.py
@@ -29,6 +29,8 @@ UPLOAD_TO = os.path.join(MEDIA_ROOT, 'test_upload')
@override_settings(MEDIA_ROOT=MEDIA_ROOT)
class FileUploadTests(TestCase):
+ urls = 'file_uploads.urls'
+
@classmethod
def setUpClass(cls):
if not os.path.isdir(MEDIA_ROOT):
@@ -44,7 +46,7 @@ class FileUploadTests(TestCase):
'name': 'Ringo',
'file_field': fp,
}
- response = self.client.post('/file_uploads/upload/', post_data)
+ response = self.client.post('/upload/', post_data)
self.assertEqual(response.status_code, 200)
def test_large_upload(self):
@@ -71,7 +73,7 @@ class FileUploadTests(TestCase):
except AttributeError:
post_data[key + '_hash'] = hashlib.sha1(force_bytes(post_data[key])).hexdigest()
- response = self.client.post('/file_uploads/verify/', post_data)
+ response = self.client.post('/verify/', post_data)
self.assertEqual(response.status_code, 200)
@@ -87,7 +89,7 @@ class FileUploadTests(TestCase):
r = {
'CONTENT_LENGTH': len(payload),
'CONTENT_TYPE': client.MULTIPART_CONTENT,
- 'PATH_INFO': "/file_uploads/echo_content/",
+ 'PATH_INFO': "/echo_content/",
'REQUEST_METHOD': 'POST',
'wsgi.input': payload,
}
@@ -115,7 +117,7 @@ class FileUploadTests(TestCase):
'file_unicode': file1,
}
- response = self.client.post('/file_uploads/unicode_name/', post_data)
+ response = self.client.post('/unicode_name/', post_data)
self.assertEqual(response.status_code, 200)
@@ -154,7 +156,7 @@ class FileUploadTests(TestCase):
r = {
'CONTENT_LENGTH': len(payload),
'CONTENT_TYPE': client.MULTIPART_CONTENT,
- 'PATH_INFO': "/file_uploads/echo/",
+ 'PATH_INFO': "/echo/",
'REQUEST_METHOD': 'POST',
'wsgi.input': payload,
}
@@ -191,7 +193,7 @@ class FileUploadTests(TestCase):
r = {
'CONTENT_LENGTH': len(payload),
'CONTENT_TYPE': client.MULTIPART_CONTENT,
- 'PATH_INFO': "/file_uploads/echo/",
+ 'PATH_INFO': "/echo/",
'REQUEST_METHOD': 'POST',
'wsgi.input': payload,
}
@@ -215,7 +217,7 @@ class FileUploadTests(TestCase):
simple_file.seek(0)
simple_file.content_type = 'text/plain; test-key=test_value'
- response = self.client.post('/file_uploads/echo_content_type_extra/', {
+ response = self.client.post('/echo_content_type_extra/', {
'no_content_type': no_content_type,
'simple_file': simple_file,
})
@@ -242,7 +244,7 @@ class FileUploadTests(TestCase):
r = {
'CONTENT_LENGTH': len(payload),
'CONTENT_TYPE': client.MULTIPART_CONTENT,
- 'PATH_INFO': '/file_uploads/echo/',
+ 'PATH_INFO': '/echo/',
'REQUEST_METHOD': 'POST',
'wsgi.input': payload,
}
@@ -257,7 +259,7 @@ class FileUploadTests(TestCase):
r = {
'CONTENT_LENGTH': 0,
'CONTENT_TYPE': client.MULTIPART_CONTENT,
- 'PATH_INFO': '/file_uploads/echo/',
+ 'PATH_INFO': '/echo/',
'REQUEST_METHOD': 'POST',
'wsgi.input': client.FakePayload(b''),
}
@@ -276,12 +278,12 @@ class FileUploadTests(TestCase):
bigfile.seek(0)
# Small file posting should work.
- response = self.client.post('/file_uploads/quota/', {'f': smallfile})
+ response = self.client.post('/quota/', {'f': smallfile})
got = json.loads(response.content.decode('utf-8'))
self.assertTrue('f' in got)
# Large files don't go through.
- response = self.client.post("/file_uploads/quota/", {'f': bigfile})
+ response = self.client.post("/quota/", {'f': bigfile})
got = json.loads(response.content.decode('utf-8'))
self.assertTrue('f' not in got)
@@ -294,7 +296,7 @@ class FileUploadTests(TestCase):
self.assertRaises(
AttributeError,
self.client.post,
- '/file_uploads/quota/broken/',
+ '/quota/broken/',
{'f': f}
)
@@ -311,7 +313,7 @@ class FileUploadTests(TestCase):
file2a.write(b'a' * (5 * 2 ** 20))
file2a.seek(0)
- response = self.client.post('/file_uploads/getlist_count/', {
+ response = self.client.post('/getlist_count/', {
'file1': file1,
'field1': 'test',
'field2': 'test3',
@@ -357,7 +359,7 @@ class FileUploadTests(TestCase):
'file_field': fp,
}
try:
- self.client.post('/file_uploads/upload_errors/', post_data)
+ self.client.post('/upload_errors/', post_data)
except reference_error.__class__ as err:
self.assertFalse(
str(err) == str(reference_error),
@@ -386,7 +388,7 @@ class FileUploadTests(TestCase):
'--%(boundary)s--\r\n',
]
response = self.client.post(
- '/file_uploads/filename_case/',
+ '/filename_case/',
'\r\n'.join(post_data) % vars,
'multipart/form-data; boundary=%(boundary)s' % vars
)