-
From e5fbf9087a0ea2e688e7fd351b174c88eba3e5a6 Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 12:10:06 +0300
Subject: [PATCH 01/12] Fixing camel case test names.
---
tests/admin_custom_urls/tests.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py
index f804036..edabb6e 100644
a
|
b
|
class AdminCustomUrlsTest(TestCase):
|
25 | 25 | def tearDown(self): |
26 | 26 | self.client.logout() |
27 | 27 | |
28 | | def testBasicAddGet(self): |
| 28 | def test_basic_add_GET(self): |
29 | 29 | """ |
30 | 30 | Ensure GET on the add_view works. |
31 | 31 | """ |
… |
… |
class AdminCustomUrlsTest(TestCase):
|
33 | 33 | self.assertIsInstance(response, TemplateResponse) |
34 | 34 | self.assertEqual(response.status_code, 200) |
35 | 35 | |
36 | | def testAddWithGETArgs(self): |
| 36 | def test_add_with_GET_args(self): |
37 | 37 | """ |
38 | 38 | Ensure GET on the add_view plus specifying a field value in the query |
39 | 39 | string works. |
… |
… |
class AdminCustomUrlsTest(TestCase):
|
42 | 42 | self.assertEqual(response.status_code, 200) |
43 | 43 | self.assertContains(response, 'value="My Action"') |
44 | 44 | |
45 | | def testBasicAddPost(self): |
| 45 | def test_basic_add_POST(self): |
46 | 46 | """ |
47 | 47 | Ensure POST on add_view works. |
48 | 48 | """ |
… |
… |
class AdminCustomUrlsTest(TestCase):
|
56 | 56 | self.assertContains(response, 'dismissAddAnotherPopup') |
57 | 57 | self.assertContains(response, 'Action added through a popup') |
58 | 58 | |
59 | | def testAdminUrlsNoClash(self): |
| 59 | def test_admin_URLs_no_clash(self): |
60 | 60 | """ |
61 | 61 | Test that some admin URLs work correctly. |
62 | 62 | """ |
-
--
1.9.1
From b18def65987d7c4903ad00f84b1b42780b09a8d2 Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 13:07:36 +0300
Subject: [PATCH 02/12] Changed camel case test names.
---
tests/admin_views/tests.py | 152 ++++++++++++++++++++++-----------------------
1 file changed, 76 insertions(+), 76 deletions(-)
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index f1d2dab..32c1883 100644
a
|
b
|
class AdminViewBasicTestCase(TestCase):
|
92 | 92 | |
93 | 93 | |
94 | 94 | class AdminViewBasicTest(AdminViewBasicTestCase): |
95 | | def testTrailingSlashRequired(self): |
| 95 | def test_trailing_slash_required(self): |
96 | 96 | """ |
97 | 97 | If you leave off the trailing slash, app should redirect and add it. |
98 | 98 | """ |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
101 | 101 | '/test_admin/%s/admin_views/article/add/' % self.urlbit, |
102 | 102 | status_code=301) |
103 | 103 | |
104 | | def testBasicAddGet(self): |
| 104 | def test_basic_add_GET(self): |
105 | 105 | """ |
106 | 106 | A smoke test to ensure GET on the add_view works. |
107 | 107 | """ |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
109 | 109 | self.assertIsInstance(response, TemplateResponse) |
110 | 110 | self.assertEqual(response.status_code, 200) |
111 | 111 | |
112 | | def testAddWithGETArgs(self): |
| 112 | def test_add_with_GET_args(self): |
113 | 113 | response = self.client.get('/test_admin/%s/admin_views/section/add/' % self.urlbit, {'name': 'My Section'}) |
114 | 114 | self.assertEqual(response.status_code, 200) |
115 | 115 | self.assertContains(response, 'value="My Section"', |
116 | 116 | msg_prefix="Couldn't find an input with the right value in the response") |
117 | 117 | |
118 | | def testBasicEditGet(self): |
| 118 | def test_basic_edit_GET(self): |
119 | 119 | """ |
120 | 120 | A smoke test to ensure GET on the change_view works. |
121 | 121 | """ |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
123 | 123 | self.assertIsInstance(response, TemplateResponse) |
124 | 124 | self.assertEqual(response.status_code, 200) |
125 | 125 | |
126 | | def testBasicEditGetStringPK(self): |
| 126 | def test_basic_edit_GET_string_PK(self): |
127 | 127 | """ |
128 | 128 | Ensure GET on the change_view works (returns an HTTP 404 error, see |
129 | 129 | #11191) when passing a string as the PK argument for a model with an |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
132 | 132 | response = self.client.get('/test_admin/%s/admin_views/section/abc/' % self.urlbit) |
133 | 133 | self.assertEqual(response.status_code, 404) |
134 | 134 | |
135 | | def testBasicInheritanceGetStringPK(self): |
| 135 | def test_basic_inheritance_GET_string_PK(self): |
136 | 136 | """ |
137 | 137 | Ensure GET on the change_view works on inherited models (returns an |
138 | 138 | HTTP 404 error, see #19951) when passing a string as the PK argument |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
141 | 141 | response = self.client.get('/test_admin/%s/admin_views/supervillain/abc/' % self.urlbit) |
142 | 142 | self.assertEqual(response.status_code, 404) |
143 | 143 | |
144 | | def testBasicAddPost(self): |
| 144 | def test_basic_add_POST(self): |
145 | 145 | """ |
146 | 146 | A smoke test to ensure POST on add_view works. |
147 | 147 | """ |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
155 | 155 | response = self.client.post('/test_admin/%s/admin_views/section/add/' % self.urlbit, post_data) |
156 | 156 | self.assertEqual(response.status_code, 302) # redirect somewhere |
157 | 157 | |
158 | | def testPopupAddPost(self): |
| 158 | def test_popup_add_POST(self): |
159 | 159 | """ |
160 | 160 | Ensure http response from a popup is properly escaped. |
161 | 161 | """ |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
212 | 212 | "article_set-5-date_1": "", |
213 | 213 | } |
214 | 214 | |
215 | | def testBasicEditPost(self): |
| 215 | def test_basic_edit_POST(self): |
216 | 216 | """ |
217 | 217 | A smoke test to ensure POST on edit_view works. |
218 | 218 | """ |
219 | 219 | response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, self.inline_post_data) |
220 | 220 | self.assertEqual(response.status_code, 302) # redirect somewhere |
221 | 221 | |
222 | | def testEditSaveAs(self): |
| 222 | def test_edit_save_as(self): |
223 | 223 | """ |
224 | 224 | Test "save as". |
225 | 225 | """ |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
235 | 235 | response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, post_data) |
236 | 236 | self.assertEqual(response.status_code, 302) # redirect somewhere |
237 | 237 | |
238 | | def testChangeListSortingCallable(self): |
| 238 | def test_change_list_sorting_callable(self): |
239 | 239 | """ |
240 | 240 | Ensure we can sort on a list_display field that is a callable |
241 | 241 | (column 2 is callable_year in ArticleAdmin) |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
246 | 246 | self.assertContentBefore(response, 'Middle content', 'Newest content', |
247 | 247 | "Results of sorting on callable are out of order.") |
248 | 248 | |
249 | | def testChangeListSortingModel(self): |
| 249 | def test_change_list_sorting_model(self): |
250 | 250 | """ |
251 | 251 | Ensure we can sort on a list_display field that is a Model method |
252 | 252 | (column 3 is 'model_year' in ArticleAdmin) |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
257 | 257 | self.assertContentBefore(response, 'Middle content', 'Oldest content', |
258 | 258 | "Results of sorting on Model method are out of order.") |
259 | 259 | |
260 | | def testChangeListSortingModelAdmin(self): |
| 260 | def test_change_list_sorting_model_admin(self): |
261 | 261 | """ |
262 | 262 | Ensure we can sort on a list_display field that is a ModelAdmin method |
263 | 263 | (column 4 is 'modeladmin_year' in ArticleAdmin) |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
268 | 268 | self.assertContentBefore(response, 'Middle content', 'Newest content', |
269 | 269 | "Results of sorting on ModelAdmin method are out of order.") |
270 | 270 | |
271 | | def testChangeListSortingModelAdminReverse(self): |
| 271 | def test_change_list_sorting_model_admin_reverse(self): |
272 | 272 | """ |
273 | 273 | Ensure we can sort on a list_display field that is a ModelAdmin |
274 | 274 | method in reverse order (i.e. admin_order_field uses the '-' prefix) |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
287 | 287 | self.assertContentBefore(response, '2008', '2009', |
288 | 288 | "Results of sorting on ModelAdmin method are out of order.") |
289 | 289 | |
290 | | def testChangeListSortingMultiple(self): |
| 290 | def test_change_list_sorting_multiple(self): |
291 | 291 | p1 = Person.objects.create(name="Chris", gender=1, alive=True) |
292 | 292 | p2 = Person.objects.create(name="Chris", gender=2, alive=True) |
293 | 293 | p3 = Person.objects.create(name="Bob", gender=1, alive=True) |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
307 | 307 | self.assertContentBefore(response, link2, link3) |
308 | 308 | self.assertContentBefore(response, link3, link1) |
309 | 309 | |
310 | | def testChangeListSortingPreserveQuerySetOrdering(self): |
| 310 | def test_change_list_sorting_preserve_query_set_ordering(self): |
311 | 311 | """ |
312 | 312 | If no ordering is defined in `ModelAdmin.ordering` or in the query |
313 | 313 | string, then the underlying order of the queryset should not be |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
327 | 327 | self.assertContentBefore(response, link3, link2) |
328 | 328 | self.assertContentBefore(response, link2, link1) |
329 | 329 | |
330 | | def testChangeListSortingModelMeta(self): |
| 330 | def test_change_list_sorting_model_meta(self): |
331 | 331 | # Test ordering on Model Meta is respected |
332 | 332 | |
333 | 333 | l1 = Language.objects.create(iso='ur', name='Urdu') |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
342 | 342 | response = self.client.get('/test_admin/admin/admin_views/language/', {'o': '-1'}) |
343 | 343 | self.assertContentBefore(response, link1, link2) |
344 | 344 | |
345 | | def testChangeListSortingOverrideModelAdmin(self): |
| 345 | def test_change_list_sorting_override_model_admin(self): |
346 | 346 | # Test ordering on Model Admin is respected, and overrides Model Meta |
347 | 347 | dt = datetime.datetime.now() |
348 | 348 | p1 = Podcast.objects.create(name="A", release_date=dt) |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
353 | 353 | response = self.client.get('/test_admin/admin/admin_views/podcast/', {}) |
354 | 354 | self.assertContentBefore(response, link1, link2) |
355 | 355 | |
356 | | def testMultipleSortSameField(self): |
| 356 | def test_multiple_sort_same_field(self): |
357 | 357 | # Check that we get the columns we expect if we have two columns |
358 | 358 | # that correspond to the same ordering field |
359 | 359 | dt = datetime.datetime.now() |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
383 | 383 | # Check sorting - should be by name |
384 | 384 | self.assertContentBefore(response, link2, link1) |
385 | 385 | |
386 | | def testSortIndicatorsAdminOrder(self): |
| 386 | def test_sort_indicators_admin_order(self): |
387 | 387 | """ |
388 | 388 | Ensures that the admin shows default sort indicators for all |
389 | 389 | kinds of 'ordering' fields: field names, method on the model |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
409 | 409 | self.assertContentBefore(response, 'The First Item', 'The Middle Item') |
410 | 410 | self.assertContentBefore(response, 'The Middle Item', 'The Last Item') |
411 | 411 | |
412 | | def testLimitedFilter(self): |
| 412 | def test_limited_filter(self): |
413 | 413 | """Ensure admin changelist filters do not contain objects excluded via limit_choices_to. |
414 | 414 | This also tests relation-spanning filters (e.g. 'color__value'). |
415 | 415 | """ |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
420 | 420 | self.assertNotContains(response, '<a href="?color__id__exact=3">Blue</a>', |
421 | 421 | msg_prefix="Changelist filter not correctly limited by limit_choices_to") |
422 | 422 | |
423 | | def testRelationSpanningFilters(self): |
| 423 | def test_relation_spanning_filters(self): |
424 | 424 | response = self.client.get('/test_admin/%s/admin_views/chapterxtra1/' % |
425 | 425 | self.urlbit) |
426 | 426 | self.assertEqual(response.status_code, 200) |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
459 | 459 | for obj in filtered_response.context['cl'].queryset.all(): |
460 | 460 | self.assertTrue(params['test'](obj, value)) |
461 | 461 | |
462 | | def testIncorrectLookupParameters(self): |
| 462 | def test_incorrect_lookup_parameters(self): |
463 | 463 | """Ensure incorrect lookup parameters are handled gracefully.""" |
464 | 464 | response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'notarealfield': '5'}) |
465 | 465 | self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit) |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
475 | 475 | response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'pub_date__gte': 'foo'}) |
476 | 476 | self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit) |
477 | 477 | |
478 | | def testIsNullLookups(self): |
| 478 | def test_is_null_lookups(self): |
479 | 479 | """Ensure is_null is handled correctly.""" |
480 | 480 | Article.objects.create(title="I Could Go Anywhere", content="Versatile", date=datetime.datetime.now()) |
481 | 481 | response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit) |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
489 | 489 | response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit, {'section__isnull': '1'}) |
490 | 490 | self.assertContains(response, '1 article') |
491 | 491 | |
492 | | def testLogoutAndPasswordChangeURLs(self): |
| 492 | def test_logout_and_password_change_URLs(self): |
493 | 493 | response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit) |
494 | 494 | self.assertContains(response, '<a href="/test_admin/%s/logout/">' % self.urlbit) |
495 | 495 | self.assertContains(response, '<a href="/test_admin/%s/password_change/">' % self.urlbit) |
496 | 496 | |
497 | | def testNamedGroupFieldChoicesChangeList(self): |
| 497 | def test_named_group_field_choices_change_list(self): |
498 | 498 | """ |
499 | 499 | Ensures the admin changelist shows correct values in the relevant column |
500 | 500 | for rows corresponding to instances of a model in which a named group |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
507 | 507 | self.assertContains(response, '<a href="%s">Horizontal</a>' % link1, msg_prefix=fail_msg, html=True) |
508 | 508 | self.assertContains(response, '<a href="%s">Vertical</a>' % link2, msg_prefix=fail_msg, html=True) |
509 | 509 | |
510 | | def testNamedGroupFieldChoicesFilter(self): |
| 510 | def test_named_group_field_choices_filter(self): |
511 | 511 | """ |
512 | 512 | Ensures the filter UI shows correctly when at least one named group has |
513 | 513 | been used in the choices option of a model field. |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
520 | 520 | self.assertContains(response, |
521 | 521 | '<a href="?surface__exact=y">Vertical</a>', msg_prefix=fail_msg, html=True) |
522 | 522 | |
523 | | def testChangeListNullBooleanDisplay(self): |
| 523 | def test_change_list_null_boolean_display(self): |
524 | 524 | Post.objects.create(public=None) |
525 | 525 | # This hard-codes the URl because it'll fail if it runs |
526 | 526 | # against the 'admin2' custom admin (which doesn't have the |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
528 | 528 | response = self.client.get("/test_admin/admin/admin_views/post/") |
529 | 529 | self.assertContains(response, 'icon-unknown.gif') |
530 | 530 | |
531 | | def testI18NLanguageNonEnglishDefault(self): |
| 531 | def test_i18n_language_non_english_default(self): |
532 | 532 | """ |
533 | 533 | Check if the JavaScript i18n view returns an empty language catalog |
534 | 534 | if the default language is non-English but the selected language |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
538 | 538 | response = self.client.get('/test_admin/admin/jsi18n/') |
539 | 539 | self.assertNotContains(response, 'Choisir une heure') |
540 | 540 | |
541 | | def testI18NLanguageNonEnglishFallback(self): |
| 541 | def test_i18n_language_non_english_fallback(self): |
542 | 542 | """ |
543 | 543 | Makes sure that the fallback language is still working properly |
544 | 544 | in cases where the selected language cannot be found. |
… |
… |
class AdminViewBasicTest(AdminViewBasicTestCase):
|
547 | 547 | response = self.client.get('/test_admin/admin/jsi18n/') |
548 | 548 | self.assertContains(response, 'Choisir une heure') |
549 | 549 | |
550 | | def testL10NDeactivated(self): |
| 550 | def test_L10N_deactivated(self): |
551 | 551 | """ |
552 | 552 | Check if L10N is deactivated, the JavaScript i18n view doesn't |
553 | 553 | return localized date/time formats. Refs #14824. |
… |
… |
class AdminViewFormUrlTest(TestCase):
|
789 | 789 | def tearDown(self): |
790 | 790 | self.client.logout() |
791 | 791 | |
792 | | def testChangeFormUrlHasCorrectValue(self): |
| 792 | def test_change_form_URL_has_correct_value(self): |
793 | 793 | """ |
794 | 794 | Tests whether change_view has form_url in response.context |
795 | 795 | """ |
… |
… |
class AdminViewFormUrlTest(TestCase):
|
797 | 797 | self.assertTrue('form_url' in response.context, msg='form_url not present in response.context') |
798 | 798 | self.assertEqual(response.context['form_url'], 'pony') |
799 | 799 | |
800 | | def testInitialDataCanBeOverridden(self): |
| 800 | def test_initial_data_can_be_overridden(self): |
801 | 801 | """ |
802 | 802 | Tests that the behavior for setting initial |
803 | 803 | form data can be overridden in the ModelAdmin class. |
… |
… |
class SaveAsTests(TestCase):
|
891 | 891 | class CustomModelAdminTest(AdminViewBasicTestCase): |
892 | 892 | urlbit = "admin2" |
893 | 893 | |
894 | | def testCustomAdminSiteLoginForm(self): |
| 894 | def test_custom_admin_site_login_form(self): |
895 | 895 | self.client.logout() |
896 | 896 | response = self.client.get('/test_admin/admin2/', follow=True) |
897 | 897 | self.assertIsInstance(response, TemplateResponse) |
… |
… |
class CustomModelAdminTest(AdminViewBasicTestCase):
|
905 | 905 | self.assertEqual(login.status_code, 200) |
906 | 906 | self.assertContains(login, 'custom form error') |
907 | 907 | |
908 | | def testCustomAdminSiteLoginTemplate(self): |
| 908 | def test_custom_admin_site_login_template(self): |
909 | 909 | self.client.logout() |
910 | 910 | response = self.client.get('/test_admin/admin2/', follow=True) |
911 | 911 | self.assertIsInstance(response, TemplateResponse) |
912 | 912 | self.assertTemplateUsed(response, 'custom_admin/login.html') |
913 | 913 | self.assertContains(response, 'Hello from a custom login template') |
914 | 914 | |
915 | | def testCustomAdminSiteLogoutTemplate(self): |
| 915 | def test_custom_admin_site_logout_template(self): |
916 | 916 | response = self.client.get('/test_admin/admin2/logout/') |
917 | 917 | self.assertIsInstance(response, TemplateResponse) |
918 | 918 | self.assertTemplateUsed(response, 'custom_admin/logout.html') |
919 | 919 | self.assertContains(response, 'Hello from a custom logout template') |
920 | 920 | |
921 | | def testCustomAdminSiteIndexViewAndTemplate(self): |
| 921 | def test_custom_admin_site_index_view_and_template(self): |
922 | 922 | try: |
923 | 923 | response = self.client.get('/test_admin/admin2/') |
924 | 924 | except TypeError: |
… |
… |
class CustomModelAdminTest(AdminViewBasicTestCase):
|
927 | 927 | self.assertTemplateUsed(response, 'custom_admin/index.html') |
928 | 928 | self.assertContains(response, 'Hello from a custom index template *bar*') |
929 | 929 | |
930 | | def testCustomAdminSiteAppIndexViewandTemplate(self): |
| 930 | def test_custom_admin_site_app_index_view_and_template(self): |
931 | 931 | response = self.client.get('/test_admin/admin2/admin_views/') |
932 | 932 | self.assertIsInstance(response, TemplateResponse) |
933 | 933 | self.assertTemplateUsed(response, 'custom_admin/app_index.html') |
934 | 934 | self.assertContains(response, 'Hello from a custom app_index template') |
935 | 935 | |
936 | | def testCustomAdminSitePasswordChangeTemplate(self): |
| 936 | def test_custom_admin_site_password_change_template(self): |
937 | 937 | response = self.client.get('/test_admin/admin2/password_change/') |
938 | 938 | self.assertIsInstance(response, TemplateResponse) |
939 | 939 | self.assertTemplateUsed(response, 'custom_admin/password_change_form.html') |
940 | 940 | self.assertContains(response, 'Hello from a custom password change form template') |
941 | 941 | |
942 | | def testCustomAdminSitePasswordChangeDoneTemplate(self): |
| 942 | def test_custom_admin_site_password_change_done_template(self): |
943 | 943 | response = self.client.get('/test_admin/admin2/password_change/done/') |
944 | 944 | self.assertIsInstance(response, TemplateResponse) |
945 | 945 | self.assertTemplateUsed(response, 'custom_admin/password_change_done.html') |
946 | 946 | self.assertContains(response, 'Hello from a custom password change done template') |
947 | 947 | |
948 | | def testCustomAdminSiteView(self): |
| 948 | def test_custom_admin_site_view(self): |
949 | 949 | self.client.login(username='super', password='secret') |
950 | 950 | response = self.client.get('/test_admin/%s/my_view/' % self.urlbit) |
951 | 951 | self.assertEqual(response.content, b"Django is a magical pony!") |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1040 | 1040 | 'password': 'secret', |
1041 | 1041 | } |
1042 | 1042 | |
1043 | | def testLogin(self): |
| 1043 | def test_login(self): |
1044 | 1044 | """ |
1045 | 1045 | Make sure only staff members can log in. |
1046 | 1046 | |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1110 | 1110 | form = login.context[0].get('form') |
1111 | 1111 | self.assertEqual(form.errors['username'][0], 'This field is required.') |
1112 | 1112 | |
1113 | | def testLoginSuccessfullyRedirectsToOriginalUrl(self): |
| 1113 | def test_login_successfully_redirects_to_original_URL(self): |
1114 | 1114 | response = self.client.get('/test_admin/admin/') |
1115 | 1115 | self.assertEqual(response.status_code, 302) |
1116 | 1116 | query_string = 'the-answer=42' |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1123 | 1123 | post_data) |
1124 | 1124 | self.assertRedirects(login, redirect_url) |
1125 | 1125 | |
1126 | | def testDoubleLoginIsNotAllowed(self): |
| 1126 | def test_double_login_is_not_allowed(self): |
1127 | 1127 | """Regression test for #19327""" |
1128 | 1128 | login_url = reverse('admin:login') + '?next=/test_admin/admin/' |
1129 | 1129 | |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1151 | 1151 | self.assertFalse(login.context) |
1152 | 1152 | self.client.get('/test_admin/admin/logout/') |
1153 | 1153 | |
1154 | | def testAddView(self): |
| 1154 | def test_add_view(self): |
1155 | 1155 | """Test add view restricts access and actually adds items.""" |
1156 | 1156 | |
1157 | 1157 | login_url = reverse('admin:login') + '?next=/test_admin/admin/' |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1207 | 1207 | # make sure the view removes test cookie |
1208 | 1208 | self.assertEqual(self.client.session.test_cookie_worked(), False) |
1209 | 1209 | |
1210 | | def testChangeView(self): |
| 1210 | def test_change_view(self): |
1211 | 1211 | """Change view should restrict access and allow users to edit items.""" |
1212 | 1212 | |
1213 | 1213 | login_url = reverse('admin:login') + '?next=/test_admin/admin/' |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1285 | 1285 | self.assertContains(response, 'login-form') |
1286 | 1286 | self.client.get('/test_admin/admin/logout/') |
1287 | 1287 | |
1288 | | def testHistoryView(self): |
| 1288 | def test_history_view(self): |
1289 | 1289 | """History view should restrict access.""" |
1290 | 1290 | |
1291 | 1291 | login_url = reverse('admin:login') + '?next=/test_admin/admin/' |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1327 | 1327 | |
1328 | 1328 | self.client.get('/test_admin/admin/logout/') |
1329 | 1329 | |
1330 | | def testConditionallyShowAddSectionLink(self): |
| 1330 | def test_conditionally_show_add_section_link(self): |
1331 | 1331 | """ |
1332 | 1332 | The foreign key widget should only show the "add related" button if the |
1333 | 1333 | user has permission to add that related item. |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1350 | 1350 | response = self.client.get(url) |
1351 | 1351 | self.assertContains(response, add_link_text) |
1352 | 1352 | |
1353 | | def testCustomModelAdminTemplates(self): |
| 1353 | def test_custom_model_admin_templates(self): |
1354 | 1354 | login_url = reverse('admin:login') + '?next=/test_admin/admin/' |
1355 | 1355 | self.client.get('/test_admin/admin/') |
1356 | 1356 | self.client.post(login_url, self.super_login) |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1391 | 1391 | |
1392 | 1392 | self.client.get('/test_admin/admin/logout/') |
1393 | 1393 | |
1394 | | def testDeleteView(self): |
| 1394 | def test_delete_view(self): |
1395 | 1395 | """Delete view should restrict access and actually delete items.""" |
1396 | 1396 | |
1397 | 1397 | login_url = reverse('admin:login') + '?next=/test_admin/admin/' |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1426 | 1426 | self.assertEqual(logged.object_id, '1') |
1427 | 1427 | self.client.get('/test_admin/admin/logout/') |
1428 | 1428 | |
1429 | | def testDisabledPermissionsWhenLoggedIn(self): |
| 1429 | def test_disabled_permissions_when_logged_in(self): |
1430 | 1430 | self.client.login(username='super', password='secret') |
1431 | 1431 | superuser = User.objects.get(username='super') |
1432 | 1432 | superuser.is_active = False |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1439 | 1439 | response = self.client.get('/test_admin/admin/secure-view/', follow=True) |
1440 | 1440 | self.assertContains(response, 'id="login-form"') |
1441 | 1441 | |
1442 | | def testDisabledStaffPermissionsWhenLoggedIn(self): |
| 1442 | def test_disabled_staff_permissions_when_logged_in(self): |
1443 | 1443 | self.client.login(username='super', password='secret') |
1444 | 1444 | superuser = User.objects.get(username='super') |
1445 | 1445 | superuser.is_staff = False |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1452 | 1452 | response = self.client.get('/test_admin/admin/secure-view/', follow=True) |
1453 | 1453 | self.assertContains(response, 'id="login-form"') |
1454 | 1454 | |
1455 | | def testAppIndexFailEarly(self): |
| 1455 | def test_app_index_fail_early(self): |
1456 | 1456 | """ |
1457 | 1457 | If a user has no module perms, avoid iterating over all the modeladmins |
1458 | 1458 | in the registry. |
… |
… |
class AdminViewUnicodeTest(TestCase):
|
1901 | 1901 | def tearDown(self): |
1902 | 1902 | self.client.logout() |
1903 | 1903 | |
1904 | | def testUnicodeEdit(self): |
| 1904 | def test_unicode_edit(self): |
1905 | 1905 | """ |
1906 | 1906 | A test to ensure that POST on edit_view handles non-ASCII characters. |
1907 | 1907 | """ |
… |
… |
class AdminViewUnicodeTest(TestCase):
|
1934 | 1934 | response = self.client.post('/test_admin/admin/admin_views/book/1/', post_data) |
1935 | 1935 | self.assertEqual(response.status_code, 302) # redirect somewhere |
1936 | 1936 | |
1937 | | def testUnicodeDelete(self): |
| 1937 | def test_unicode_delete(self): |
1938 | 1938 | """ |
1939 | 1939 | Ensure that the delete_view handles non-ASCII characters |
1940 | 1940 | """ |
… |
… |
class AdminInheritedInlinesTest(TestCase):
|
2404 | 2404 | def tearDown(self): |
2405 | 2405 | self.client.logout() |
2406 | 2406 | |
2407 | | def testInline(self): |
| 2407 | def test_inline(self): |
2408 | 2408 | "Ensure that inline models which inherit from a common parent are correctly handled by admin." |
2409 | 2409 | |
2410 | 2410 | foo_user = "foo username" |
… |
… |
class AdminActionsTest(TestCase):
|
2563 | 2563 | self.assertContains(response, '<li>Answer: <a href="/test_admin/admin/admin_views/answer/%s/">Because.</a></li>' % a1.pk, html=True) |
2564 | 2564 | self.assertContains(response, '<li>Answer: <a href="/test_admin/admin/admin_views/answer/%s/">Yes.</a></li>' % a2.pk, html=True) |
2565 | 2565 | |
2566 | | def test_model_admin_default_delete_action_no_change_url(self): |
| 2566 | def test_model_admin_default_delete_action_no_change_URL(self): |
2567 | 2567 | """ |
2568 | 2568 | Default delete action shouldn't break if a user's ModelAdmin removes the url for change_view. |
2569 | 2569 | |
… |
… |
class TestInlineNotEditable(TestCase):
|
2791 | 2791 | def tearDown(self): |
2792 | 2792 | self.client.logout() |
2793 | 2793 | |
2794 | | def test(self): |
| 2794 | def test_GET_parent_add(self): |
2795 | 2795 | """ |
2796 | 2796 | InlineModelAdmin broken? |
2797 | 2797 | """ |
… |
… |
class NeverCacheTests(TestCase):
|
3421 | 3421 | def tearDown(self): |
3422 | 3422 | self.client.logout() |
3423 | 3423 | |
3424 | | def testAdminIndex(self): |
| 3424 | def test_admin_index(self): |
3425 | 3425 | "Check the never-cache status of the main index" |
3426 | 3426 | response = self.client.get('/test_admin/admin/') |
3427 | 3427 | self.assertEqual(get_max_age(response), 0) |
3428 | 3428 | |
3429 | | def testAppIndex(self): |
| 3429 | def test_app_index(self): |
3430 | 3430 | "Check the never-cache status of an application index" |
3431 | 3431 | response = self.client.get('/test_admin/admin/admin_views/') |
3432 | 3432 | self.assertEqual(get_max_age(response), 0) |
3433 | 3433 | |
3434 | | def testModelIndex(self): |
| 3434 | def test_model_index(self): |
3435 | 3435 | "Check the never-cache status of a model index" |
3436 | 3436 | response = self.client.get('/test_admin/admin/admin_views/fabric/') |
3437 | 3437 | self.assertEqual(get_max_age(response), 0) |
3438 | 3438 | |
3439 | | def testModelAdd(self): |
| 3439 | def test_model_add(self): |
3440 | 3440 | "Check the never-cache status of a model add page" |
3441 | 3441 | response = self.client.get('/test_admin/admin/admin_views/fabric/add/') |
3442 | 3442 | self.assertEqual(get_max_age(response), 0) |
3443 | 3443 | |
3444 | | def testModelView(self): |
| 3444 | def test_model_view(self): |
3445 | 3445 | "Check the never-cache status of a model edit page" |
3446 | 3446 | response = self.client.get('/test_admin/admin/admin_views/section/1/') |
3447 | 3447 | self.assertEqual(get_max_age(response), 0) |
3448 | 3448 | |
3449 | | def testModelHistory(self): |
| 3449 | def test_model_history(self): |
3450 | 3450 | "Check the never-cache status of a model history page" |
3451 | 3451 | response = self.client.get('/test_admin/admin/admin_views/section/1/history/') |
3452 | 3452 | self.assertEqual(get_max_age(response), 0) |
3453 | 3453 | |
3454 | | def testModelDelete(self): |
| 3454 | def test_model_delete(self): |
3455 | 3455 | "Check the never-cache status of a model delete page" |
3456 | 3456 | response = self.client.get('/test_admin/admin/admin_views/section/1/delete/') |
3457 | 3457 | self.assertEqual(get_max_age(response), 0) |
3458 | 3458 | |
3459 | | def testLogin(self): |
| 3459 | def test_login(self): |
3460 | 3460 | "Check the never-cache status of login views" |
3461 | 3461 | self.client.logout() |
3462 | 3462 | response = self.client.get('/test_admin/admin/') |
3463 | 3463 | self.assertEqual(get_max_age(response), 0) |
3464 | 3464 | |
3465 | | def testLogout(self): |
| 3465 | def test_logout(self): |
3466 | 3466 | "Check the never-cache status of logout view" |
3467 | 3467 | response = self.client.get('/test_admin/admin/logout/') |
3468 | 3468 | self.assertEqual(get_max_age(response), 0) |
3469 | 3469 | |
3470 | | def testPasswordChange(self): |
| 3470 | def test_password_change(self): |
3471 | 3471 | "Check the never-cache status of the password change view" |
3472 | 3472 | self.client.logout() |
3473 | 3473 | response = self.client.get('/test_admin/password_change/') |
3474 | 3474 | self.assertEqual(get_max_age(response), None) |
3475 | 3475 | |
3476 | | def testPasswordChangeDone(self): |
| 3476 | def test_password_change_done(self): |
3477 | 3477 | "Check the never-cache status of the password change done view" |
3478 | 3478 | response = self.client.get('/test_admin/admin/password_change/done/') |
3479 | 3479 | self.assertEqual(get_max_age(response), None) |
3480 | 3480 | |
3481 | | def testJsi18n(self): |
| 3481 | def test_JS_i18n(self): |
3482 | 3482 | "Check the never-cache status of the JavaScript i18n view" |
3483 | 3483 | response = self.client.get('/test_admin/admin/jsi18n/') |
3484 | 3484 | self.assertEqual(get_max_age(response), None) |
… |
… |
class CSSTest(TestCase):
|
4116 | 4116 | self.assertContains(response, '<tr class="model-actor">') |
4117 | 4117 | self.assertContains(response, '<tr class="model-album">') |
4118 | 4118 | |
4119 | | def testAppModelInFormBodyClass(self): |
| 4119 | def test_app_model_in_form_body_class(self): |
4120 | 4120 | """ |
4121 | 4121 | Ensure app and model tag are correctly read by change_form template |
4122 | 4122 | """ |
… |
… |
class CSSTest(TestCase):
|
4125 | 4125 | self.assertContains(response, |
4126 | 4126 | '<body class=" app-admin_views model-section ') |
4127 | 4127 | |
4128 | | def testAppModelInListBodyClass(self): |
| 4128 | def test_app_model_in_list_body_class(self): |
4129 | 4129 | """ |
4130 | 4130 | Ensure app and model tag are correctly read by change_list template |
4131 | 4131 | """ |
… |
… |
class CSSTest(TestCase):
|
4134 | 4134 | self.assertContains(response, |
4135 | 4135 | '<body class=" app-admin_views model-section ') |
4136 | 4136 | |
4137 | | def testAppModelInDeleteConfirmationBodyClass(self): |
| 4137 | def test_app_model_in_delete_confirmation_body_class(self): |
4138 | 4138 | """ |
4139 | 4139 | Ensure app and model tag are correctly read by delete_confirmation |
4140 | 4140 | template |
… |
… |
class CSSTest(TestCase):
|
4145 | 4145 | self.assertContains(response, |
4146 | 4146 | '<body class=" app-admin_views model-section ') |
4147 | 4147 | |
4148 | | def testAppModelInAppIndexBodyClass(self): |
| 4148 | def test_app_model_in_app_index_body_class(self): |
4149 | 4149 | """ |
4150 | 4150 | Ensure app and model tag are correctly read by app_index template |
4151 | 4151 | """ |
… |
… |
class CSSTest(TestCase):
|
4153 | 4153 | self.assertEqual(response.status_code, 200) |
4154 | 4154 | self.assertContains(response, '<body class=" dashboard app-admin_views') |
4155 | 4155 | |
4156 | | def testAppModelInDeleteSelectedConfirmationBodyClass(self): |
| 4156 | def test_app_model_in_delete_selected_confirmation_body_class(self): |
4157 | 4157 | """ |
4158 | 4158 | Ensure app and model tag are correctly read by |
4159 | 4159 | delete_selected_confirmation template |
… |
… |
class ValidXHTMLTests(TestCase):
|
4254 | 4254 | global_settings.TEMPLATE_CONTEXT_PROCESSORS), |
4255 | 4255 | USE_I18N=False, |
4256 | 4256 | ) |
4257 | | def testLangNamePresent(self): |
| 4257 | def test_lang_name_present(self): |
4258 | 4258 | response = self.client.get('/test_admin/%s/admin_views/' % self.urlbit) |
4259 | 4259 | self.assertNotContains(response, ' lang=""') |
4260 | 4260 | self.assertNotContains(response, ' xml:lang=""') |
-
--
1.9.1
From 0970cf6149b3f630a0c029b5decb904c5b3aab58 Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 15:57:47 +0300
Subject: [PATCH 03/12] Modified camel case test names.
---
tests/admin_widgets/tests.py | 52 ++++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index 39f89f6..fb055da 100644
a
|
b
|
class AdminFormfieldForDBFieldTests(TestCase):
|
71 | 71 | # Return the formfield so that other tests can continue |
72 | 72 | return ff |
73 | 73 | |
74 | | def testDateField(self): |
| 74 | def test_DateField(self): |
75 | 75 | self.assertFormfield(models.Event, 'start_date', widgets.AdminDateWidget) |
76 | 76 | |
77 | | def testDateTimeField(self): |
| 77 | def test_DateTimeField(self): |
78 | 78 | self.assertFormfield(models.Member, 'birthdate', widgets.AdminSplitDateTime) |
79 | 79 | |
80 | | def testTimeField(self): |
| 80 | def test_TimeField(self): |
81 | 81 | self.assertFormfield(models.Event, 'start_time', widgets.AdminTimeWidget) |
82 | 82 | |
83 | | def testTextField(self): |
| 83 | def test_TextField(self): |
84 | 84 | self.assertFormfield(models.Event, 'description', widgets.AdminTextareaWidget) |
85 | 85 | |
86 | | def testURLField(self): |
| 86 | def test_URLField(self): |
87 | 87 | self.assertFormfield(models.Event, 'link', widgets.AdminURLFieldWidget) |
88 | 88 | |
89 | | def testIntegerField(self): |
| 89 | def test_IntegerField(self): |
90 | 90 | self.assertFormfield(models.Event, 'min_age', widgets.AdminIntegerFieldWidget) |
91 | 91 | |
92 | | def testCharField(self): |
| 92 | def test_CharField(self): |
93 | 93 | self.assertFormfield(models.Member, 'name', widgets.AdminTextInputWidget) |
94 | 94 | |
95 | | def testEmailField(self): |
| 95 | def test_EmailField(self): |
96 | 96 | self.assertFormfield(models.Member, 'email', widgets.AdminEmailInputWidget) |
97 | 97 | |
98 | | def testFileField(self): |
| 98 | def test_FileField(self): |
99 | 99 | self.assertFormfield(models.Album, 'cover_art', widgets.AdminFileWidget) |
100 | 100 | |
101 | | def testForeignKey(self): |
| 101 | def test_ForeignKey(self): |
102 | 102 | self.assertFormfield(models.Event, 'main_band', forms.Select) |
103 | 103 | |
104 | | def testRawIDForeignKey(self): |
| 104 | def test_raw_ID_ForeignKey(self): |
105 | 105 | self.assertFormfield(models.Event, 'main_band', widgets.ForeignKeyRawIdWidget, |
106 | 106 | raw_id_fields=['main_band']) |
107 | 107 | |
108 | | def testRadioFieldsForeignKey(self): |
| 108 | def test_radio_fields_ForeignKey(self): |
109 | 109 | ff = self.assertFormfield(models.Event, 'main_band', widgets.AdminRadioSelect, |
110 | 110 | radio_fields={'main_band': admin.VERTICAL}) |
111 | 111 | self.assertEqual(ff.empty_label, None) |
112 | 112 | |
113 | | def testManyToMany(self): |
| 113 | def test_many_to_many(self): |
114 | 114 | self.assertFormfield(models.Band, 'members', forms.SelectMultiple) |
115 | 115 | |
116 | | def testRawIDManyTOMany(self): |
| 116 | def test_raw_ID_many_to_many(self): |
117 | 117 | self.assertFormfield(models.Band, 'members', widgets.ManyToManyRawIdWidget, |
118 | 118 | raw_id_fields=['members']) |
119 | 119 | |
120 | | def testFilteredManyToMany(self): |
| 120 | def test_filtered_many_to_many(self): |
121 | 121 | self.assertFormfield(models.Band, 'members', widgets.FilteredSelectMultiple, |
122 | 122 | filter_vertical=['members']) |
123 | 123 | |
124 | | def testFormfieldOverrides(self): |
| 124 | def test_formfield_overrides(self): |
125 | 125 | self.assertFormfield(models.Event, 'start_date', forms.TextInput, |
126 | 126 | formfield_overrides={DateField: {'widget': forms.TextInput}}) |
127 | 127 | |
128 | | def testFormfieldOverridesWidgetInstances(self): |
| 128 | def test_formfield_overrides_widget_instances(self): |
129 | 129 | """ |
130 | 130 | Test that widget instances in formfield_overrides are not shared between |
131 | 131 | different fields. (#19423) |
… |
… |
class AdminFormfieldForDBFieldTests(TestCase):
|
142 | 142 | self.assertEqual(f2.widget.attrs['maxlength'], '20') |
143 | 143 | self.assertEqual(f2.widget.attrs['size'], '10') |
144 | 144 | |
145 | | def testFieldWithChoices(self): |
| 145 | def test_field_with_choices(self): |
146 | 146 | self.assertFormfield(models.Member, 'gender', forms.Select) |
147 | 147 | |
148 | | def testChoicesWithRadioFields(self): |
| 148 | def test_choices_with_radio_fields(self): |
149 | 149 | self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect, |
150 | 150 | radio_fields={'gender': admin.VERTICAL}) |
151 | 151 | |
152 | | def testInheritance(self): |
| 152 | def test_inheritance(self): |
153 | 153 | self.assertFormfield(models.Album, 'backside_art', widgets.AdminFileWidget) |
154 | 154 | |
155 | 155 | def test_m2m_widgets(self): |
… |
… |
class AdminFormfieldForDBFieldTests(TestCase):
|
169 | 169 | class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase): |
170 | 170 | fixtures = ["admin-widgets-users.xml"] |
171 | 171 | |
172 | | def testFilterChoicesByRequestUser(self): |
| 172 | def test_filter_choices_by_request_user(self): |
173 | 173 | """ |
174 | 174 | Ensure the user can only see their own cars in the foreign key dropdown. |
175 | 175 | """ |
… |
… |
class AdminForeignKeyWidgetChangeList(DjangoTestCase):
|
190 | 190 | def tearDown(self): |
191 | 191 | self.client.logout() |
192 | 192 | |
193 | | def test_changelist_foreignkey(self): |
| 193 | def test_changelist_ForeignKey(self): |
194 | 194 | response = self.client.get('/admin_widgets/car/') |
195 | 195 | self.assertContains(response, '/auth/user/add/') |
196 | 196 | |
… |
… |
class ForeignKeyRawIdWidgetTest(DjangoTestCase):
|
411 | 411 | ) |
412 | 412 | ) |
413 | 413 | |
414 | | def test_fk_related_model_not_in_admin(self): |
| 414 | def test_FK_related_model_not_in_admin(self): |
415 | 415 | # FK to a model not registered with admin site. Raw ID widget should |
416 | 416 | # have no magnifying glass link. See #16542 |
417 | 417 | big_honeycomb = models.Honeycomb.objects.create(location='Old tree') |
… |
… |
class ForeignKeyRawIdWidgetTest(DjangoTestCase):
|
424 | 424 | '<input type="text" name="honeycomb_widget" value="%(hcombpk)s" /> <strong>Honeycomb object</strong>' % {'hcombpk': big_honeycomb.pk} |
425 | 425 | ) |
426 | 426 | |
427 | | def test_fk_to_self_model_not_in_admin(self): |
| 427 | def test_FK_to_self_model_not_in_admin(self): |
428 | 428 | # FK to self, not registered with admin site. Raw ID widget should have |
429 | 429 | # no magnifying glass link. See #16542 |
430 | 430 | subject1 = models.Individual.objects.create(name='Subject #1') |
… |
… |
class AdminRawIdWidgetSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
972 | 972 | models.Band.objects.create(id=98, name='Green Potatoes') |
973 | 973 | super(AdminRawIdWidgetSeleniumFirefoxTests, self).setUp() |
974 | 974 | |
975 | | def test_foreignkey(self): |
| 975 | def test_ForeignKey(self): |
976 | 976 | self.admin_login(username='super', password='secret', login_url='/') |
977 | 977 | self.selenium.get( |
978 | 978 | '%s%s' % (self.live_server_url, '/admin_widgets/event/add/')) |
… |
… |
class RelatedFieldWidgetSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
1058 | 1058 | fixtures = ['admin-widgets-users.xml'] |
1059 | 1059 | webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' |
1060 | 1060 | |
1061 | | def test_foreign_key_using_to_field(self): |
| 1061 | def test_ForeignKey_using_to_field(self): |
1062 | 1062 | self.admin_login(username='super', password='secret', login_url='/') |
1063 | 1063 | self.selenium.get('%s%s' % ( |
1064 | 1064 | self.live_server_url, |
-
--
1.9.1
From a5b81d91f6d65c5cbe5c5fcbd126bb840033696d Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 16:00:21 +0300
Subject: [PATCH 04/12] Modified camel case test name.
---
tests/bug639/tests.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/bug639/tests.py b/tests/bug639/tests.py
index 769d27d..26e172a 100644
a
|
b
|
from .models import Photo, PhotoForm, temp_storage_dir
|
16 | 16 | |
17 | 17 | class Bug639Test(unittest.TestCase): |
18 | 18 | |
19 | | def testBug639(self): |
| 19 | def test_bug_639(self): |
20 | 20 | """ |
21 | 21 | Simulate a file upload and check how many times Model.save() gets |
22 | 22 | called. |
-
--
1.9.1
From 2a935773f8c16c42f5a77ee208d7ac8d8b9f7a71 Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 16:06:02 +0300
Subject: [PATCH 05/12] Modified camel case test names.
---
tests/conditional_processing/tests.py | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tests/conditional_processing/tests.py b/tests/conditional_processing/tests.py
index 162a405..934ca5c 100644
a
|
b
|
class ConditionalGet(TestCase):
|
31 | 31 | self.assertEqual(response.status_code, 304) |
32 | 32 | self.assertEqual(response.content, b'') |
33 | 33 | |
34 | | def testWithoutConditions(self): |
| 34 | def test_without_conditions(self): |
35 | 35 | response = self.client.get('/condition/') |
36 | 36 | self.assertFullResponse(response) |
37 | 37 | |
38 | | def testIfModifiedSince(self): |
| 38 | def test_if_modified_since(self): |
39 | 39 | self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR |
40 | 40 | response = self.client.get('/condition/') |
41 | 41 | self.assertNotModified(response) |
… |
… |
class ConditionalGet(TestCase):
|
49 | 49 | response = self.client.get('/condition/') |
50 | 50 | self.assertFullResponse(response) |
51 | 51 | |
52 | | def testIfNoneMatch(self): |
| 52 | def test_if_none_match(self): |
53 | 53 | self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG |
54 | 54 | response = self.client.get('/condition/') |
55 | 55 | self.assertNotModified(response) |
… |
… |
class ConditionalGet(TestCase):
|
62 | 62 | response = self.client.get('/condition/') |
63 | 63 | self.assertNotModified(response) |
64 | 64 | |
65 | | def testIfMatch(self): |
| 65 | def test_if_match(self): |
66 | 66 | self.client.defaults['HTTP_IF_MATCH'] = '"%s"' % ETAG |
67 | 67 | response = self.client.put('/condition/etag/') |
68 | 68 | self.assertEqual(response.status_code, 200) |
… |
… |
class ConditionalGet(TestCase):
|
70 | 70 | response = self.client.put('/condition/etag/') |
71 | 71 | self.assertEqual(response.status_code, 412) |
72 | 72 | |
73 | | def testBothHeaders(self): |
| 73 | def test_both_headers(self): |
74 | 74 | self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR |
75 | 75 | self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG |
76 | 76 | response = self.client.get('/condition/') |
… |
… |
class ConditionalGet(TestCase):
|
86 | 86 | response = self.client.get('/condition/') |
87 | 87 | self.assertFullResponse(response) |
88 | 88 | |
89 | | def testSingleCondition1(self): |
| 89 | def test_single_condition_1(self): |
90 | 90 | self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR |
91 | 91 | response = self.client.get('/condition/last_modified/') |
92 | 92 | self.assertNotModified(response) |
93 | 93 | response = self.client.get('/condition/etag/') |
94 | 94 | self.assertFullResponse(response, check_last_modified=False) |
95 | 95 | |
96 | | def testSingleCondition2(self): |
| 96 | def test_single_condition_2(self): |
97 | 97 | self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG |
98 | 98 | response = self.client.get('/condition/etag/') |
99 | 99 | self.assertNotModified(response) |
100 | 100 | response = self.client.get('/condition/last_modified/') |
101 | 101 | self.assertFullResponse(response, check_etag=False) |
102 | 102 | |
103 | | def testSingleCondition3(self): |
| 103 | def test_single_condition_3(self): |
104 | 104 | self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = EXPIRED_LAST_MODIFIED_STR |
105 | 105 | response = self.client.get('/condition/last_modified/') |
106 | 106 | self.assertFullResponse(response, check_etag=False) |
107 | 107 | |
108 | | def testSingleCondition4(self): |
| 108 | def test_single_condition_4(self): |
109 | 109 | self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % EXPIRED_ETAG |
110 | 110 | response = self.client.get('/condition/etag/') |
111 | 111 | self.assertFullResponse(response, check_last_modified=False) |
112 | 112 | |
113 | | def testSingleCondition5(self): |
| 113 | def test_single_condition_5(self): |
114 | 114 | self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR |
115 | 115 | response = self.client.get('/condition/last_modified2/') |
116 | 116 | self.assertNotModified(response) |
117 | 117 | response = self.client.get('/condition/etag2/') |
118 | 118 | self.assertFullResponse(response, check_last_modified=False) |
119 | 119 | |
120 | | def testSingleCondition6(self): |
| 120 | def test_single_condition_6(self): |
121 | 121 | self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG |
122 | 122 | response = self.client.get('/condition/etag2/') |
123 | 123 | self.assertNotModified(response) |
124 | 124 | response = self.client.get('/condition/last_modified2/') |
125 | 125 | self.assertFullResponse(response, check_etag=False) |
126 | 126 | |
127 | | def testInvalidETag(self): |
| 127 | def test_invalid_etag(self): |
128 | 128 | self.client.defaults['HTTP_IF_NONE_MATCH'] = r'"\"' |
129 | 129 | response = self.client.get('/condition/etag/') |
130 | 130 | self.assertFullResponse(response, check_last_modified=False) |
-
--
1.9.1
From 4931cff49cd56ba8deb705f848f9b1aafb17a516 Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 16:15:23 +0300
Subject: [PATCH 06/12] Modified camel case test names.
---
tests/dispatch/tests/test_dispatcher.py | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/tests/dispatch/tests/test_dispatcher.py b/tests/dispatch/tests/test_dispatcher.py
index 1bfa48a..8153cc2 100644
a
|
b
|
d_signal = Signal(providing_args=["val"], use_caching=True)
|
45 | 45 | class DispatcherTests(unittest.TestCase): |
46 | 46 | """Test suite for dispatcher (barely started)""" |
47 | 47 | |
48 | | def _testIsClean(self, signal): |
| 48 | def test_is_clean(self, signal): |
49 | 49 | """Assert that everything has been cleaned up automatically""" |
50 | 50 | # Note that dead weakref cleanup happens as side effect of using |
51 | 51 | # the signal's receivers through the signals API. So, first do a |
… |
… |
class DispatcherTests(unittest.TestCase):
|
53 | 53 | self.assertFalse(signal.has_listeners()) |
54 | 54 | self.assertEqual(signal.receivers, []) |
55 | 55 | |
56 | | def testExact(self): |
| 56 | def test_exact(self): |
57 | 57 | a_signal.connect(receiver_1_arg, sender=self) |
58 | 58 | expected = [(receiver_1_arg, "test")] |
59 | 59 | result = a_signal.send(sender=self, val="test") |
… |
… |
class DispatcherTests(unittest.TestCase):
|
61 | 61 | a_signal.disconnect(receiver_1_arg, sender=self) |
62 | 62 | self._testIsClean(a_signal) |
63 | 63 | |
64 | | def testIgnoredSender(self): |
| 64 | def test_ignored_sender(self): |
65 | 65 | a_signal.connect(receiver_1_arg) |
66 | 66 | expected = [(receiver_1_arg, "test")] |
67 | 67 | result = a_signal.send(sender=self, val="test") |
… |
… |
class DispatcherTests(unittest.TestCase):
|
69 | 69 | a_signal.disconnect(receiver_1_arg) |
70 | 70 | self._testIsClean(a_signal) |
71 | 71 | |
72 | | def testGarbageCollected(self): |
| 72 | def test_garbage_collected(self): |
73 | 73 | a = Callable() |
74 | 74 | a_signal.connect(a.a, sender=self) |
75 | 75 | expected = [] |
… |
… |
class DispatcherTests(unittest.TestCase):
|
79 | 79 | self.assertEqual(result, expected) |
80 | 80 | self._testIsClean(a_signal) |
81 | 81 | |
82 | | def testCachedGarbagedCollected(self): |
| 82 | def test_cached_garbaged_collected(self): |
83 | 83 | """ |
84 | 84 | Make sure signal caching sender receivers don't prevent garbage |
85 | 85 | collection of senders. |
… |
… |
class DispatcherTests(unittest.TestCase):
|
97 | 97 | # Disconnect after reference check since it flushes the tested cache. |
98 | 98 | d_signal.disconnect(receiver_1_arg) |
99 | 99 | |
100 | | def testMultipleRegistration(self): |
| 100 | def test_multiple_registration(self): |
101 | 101 | a = Callable() |
102 | 102 | a_signal.connect(a) |
103 | 103 | a_signal.connect(a) |
… |
… |
class DispatcherTests(unittest.TestCase):
|
113 | 113 | garbage_collect() |
114 | 114 | self._testIsClean(a_signal) |
115 | 115 | |
116 | | def testUidRegistration(self): |
| 116 | def test_uid_registration(self): |
117 | 117 | def uid_based_receiver_1(**kwargs): |
118 | 118 | pass |
119 | 119 | |
… |
… |
class DispatcherTests(unittest.TestCase):
|
126 | 126 | a_signal.disconnect(dispatch_uid="uid") |
127 | 127 | self._testIsClean(a_signal) |
128 | 128 | |
129 | | def testRobust(self): |
| 129 | def test_robust(self): |
130 | 130 | """Test the sendRobust function""" |
131 | 131 | def fails(val, **kwargs): |
132 | 132 | raise ValueError('this') |
… |
… |
class DispatcherTests(unittest.TestCase):
|
140 | 140 | a_signal.disconnect(fails) |
141 | 141 | self._testIsClean(a_signal) |
142 | 142 | |
143 | | def testDisconnection(self): |
| 143 | def test_disconnection(self): |
144 | 144 | receiver_1 = Callable() |
145 | 145 | receiver_2 = Callable() |
146 | 146 | receiver_3 = Callable() |
… |
… |
class ReceiverTestCase(unittest.TestCase):
|
170 | 170 | Test suite for receiver. |
171 | 171 | |
172 | 172 | """ |
173 | | def testReceiverSingleSignal(self): |
| 173 | def test_receiver_single_signal(self): |
174 | 174 | @receiver(a_signal) |
175 | 175 | def f(val, **kwargs): |
176 | 176 | self.state = val |
… |
… |
class ReceiverTestCase(unittest.TestCase):
|
178 | 178 | a_signal.send(sender=self, val=True) |
179 | 179 | self.assertTrue(self.state) |
180 | 180 | |
181 | | def testReceiverSignalList(self): |
| 181 | def test_receiver_signal_list(self): |
182 | 182 | @receiver([a_signal, b_signal, c_signal]) |
183 | 183 | def f(val, **kwargs): |
184 | 184 | self.state.append(val) |
-
--
1.9.1
From e81b0cd48c7fdde48a62ae3727fc45f128b4bed2 Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 16:25:11 +0300
Subject: [PATCH 07/12] Modified camel case test names.
---
tests/generic_inline_admin/tests.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py
index e73fc40..99459b9 100644
a
|
b
|
class GenericAdminViewTest(TestCase):
|
46 | 46 | def tearDown(self): |
47 | 47 | self.client.logout() |
48 | 48 | |
49 | | def testBasicAddGet(self): |
| 49 | def test_basic_add_GET(self): |
50 | 50 | """ |
51 | 51 | A smoke test to ensure GET on the add_view works. |
52 | 52 | """ |
53 | 53 | response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/add/') |
54 | 54 | self.assertEqual(response.status_code, 200) |
55 | 55 | |
56 | | def testBasicEditGet(self): |
| 56 | def test_basic_edit_GET(self): |
57 | 57 | """ |
58 | 58 | A smoke test to ensure GET on the change_view works. |
59 | 59 | """ |
60 | 60 | response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/%d/' % self.episode_pk) |
61 | 61 | self.assertEqual(response.status_code, 200) |
62 | 62 | |
63 | | def testBasicAddPost(self): |
| 63 | def test_basic_add_POST(self): |
64 | 64 | """ |
65 | 65 | A smoke test to ensure POST on add_view works. |
66 | 66 | """ |
… |
… |
class GenericAdminViewTest(TestCase):
|
74 | 74 | response = self.client.post('/generic_inline_admin/admin/generic_inline_admin/episode/add/', post_data) |
75 | 75 | self.assertEqual(response.status_code, 302) # redirect somewhere |
76 | 76 | |
77 | | def testBasicEditPost(self): |
| 77 | def test_basic_edit_POST(self): |
78 | 78 | """ |
79 | 79 | A smoke test to ensure POST on edit_view works. |
80 | 80 | """ |
… |
… |
class GenericAdminViewTest(TestCase):
|
95 | 95 | response = self.client.post(url, post_data) |
96 | 96 | self.assertEqual(response.status_code, 302) # redirect somewhere |
97 | 97 | |
98 | | def testGenericInlineFormset(self): |
| 98 | def test_generic_inline_formset(self): |
99 | 99 | EpisodeMediaFormSet = generic_inlineformset_factory(Media, can_delete=False, exclude=['description', 'keywords'], extra=3) |
100 | 100 | e = Episode.objects.get(name='This Week in Django') |
101 | 101 | |
… |
… |
class GenericAdminViewTest(TestCase):
|
119 | 119 | self.assertHTMLEqual(formset.forms[0].as_p(), '<p><label for="id_generic_inline_admin-media-content_type-object_id-0-url">Url:</label> <input id="id_generic_inline_admin-media-content_type-object_id-0-url" type="url" name="generic_inline_admin-media-content_type-object_id-0-url" value="http://example.com/logo.png" maxlength="200" /><input type="hidden" name="generic_inline_admin-media-content_type-object_id-0-id" value="%s" id="id_generic_inline_admin-media-content_type-object_id-0-id" /></p>' % self.png_media_pk) |
120 | 120 | self.assertHTMLEqual(formset.forms[1].as_p(), '<p><label for="id_generic_inline_admin-media-content_type-object_id-1-url">Url:</label> <input id="id_generic_inline_admin-media-content_type-object_id-1-url" type="url" name="generic_inline_admin-media-content_type-object_id-1-url" maxlength="200" /><input type="hidden" name="generic_inline_admin-media-content_type-object_id-1-id" id="id_generic_inline_admin-media-content_type-object_id-1-id" /></p>') |
121 | 121 | |
122 | | def testGenericInlineFormsetFactory(self): |
| 122 | def test_generic_inline_formset_factory(self): |
123 | 123 | # Regression test for #10522. |
124 | 124 | inline_formset = generic_inlineformset_factory(Media, |
125 | 125 | exclude=('url',)) |
… |
… |
class GenericInlineAdminParametersTest(TestCase):
|
153 | 153 | Media.objects.create(content_object=e, url='http://example.com/podcast.mp3') |
154 | 154 | return e |
155 | 155 | |
156 | | def testNoParam(self): |
| 156 | def test_no_param(self): |
157 | 157 | """ |
158 | 158 | With one initial form, extra (default) at 3, there should be 4 forms. |
159 | 159 | """ |
… |
… |
class GenericInlineAdminParametersTest(TestCase):
|
163 | 163 | self.assertEqual(formset.total_form_count(), 4) |
164 | 164 | self.assertEqual(formset.initial_form_count(), 1) |
165 | 165 | |
166 | | def testExtraParam(self): |
| 166 | def test_extra_param(self): |
167 | 167 | """ |
168 | 168 | With extra=0, there should be one form. |
169 | 169 | """ |
… |
… |
class GenericInlineAdminParametersTest(TestCase):
|
202 | 202 | self.assertEqual(formset.total_form_count(), 2) |
203 | 203 | self.assertEqual(formset.initial_form_count(), 1) |
204 | 204 | |
205 | | def testMinNumParam(self): |
| 205 | def test_min_num_param(self): |
206 | 206 | """ |
207 | 207 | With extra=3 and min_num=2, there should be five forms. |
208 | 208 | """ |
… |
… |
class GenericInlineAdminWithUniqueTogetherTest(TestCase):
|
234 | 234 | def tearDown(self): |
235 | 235 | self.client.logout() |
236 | 236 | |
237 | | def testAdd(self): |
| 237 | def test_add(self): |
238 | 238 | category_id = Category.objects.create(name='male').pk |
239 | 239 | post_data = { |
240 | 240 | "name": "John Doe", |
-
--
1.9.1
From 7051550346830a9ac58c192551900582ca93bf62 Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 16:42:19 +0300
Subject: [PATCH 08/12] Added camel case field names in test names.
---
tests/model_fields/tests.py | 60 ++++++++++++++++++++++-----------------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index b33314b..b18d3b2 100644
a
|
b
|
class BasicFieldTests(test.TestCase):
|
42 | 42 | form_field = model_field.formfield(show_hidden_initial=False) |
43 | 43 | self.assertFalse(form_field.show_hidden_initial) |
44 | 44 | |
45 | | def test_nullbooleanfield_blank(self): |
| 45 | def test_NullBooleanField_blank(self): |
46 | 46 | """ |
47 | 47 | Regression test for #13071: NullBooleanField should not throw |
48 | 48 | a validation error when given a value of None. |
… |
… |
class ForeignKeyTests(test.TestCase):
|
170 | 170 | self.assertEqual(b.a, a) |
171 | 171 | |
172 | 172 | @test.skipIfDBFeature('interprets_empty_strings_as_nulls') |
173 | | def test_empty_string_fk(self): |
| 173 | def test_empty_string_FK(self): |
174 | 174 | """ |
175 | 175 | Test that foreign key values to empty strings don't get converted |
176 | 176 | to None (#19299) |
… |
… |
class ForeignKeyTests(test.TestCase):
|
182 | 182 | |
183 | 183 | |
184 | 184 | class DateTimeFieldTests(unittest.TestCase): |
185 | | def test_datetimefield_to_python_usecs(self): |
| 185 | def test_DateTimeField_to_python_usecs(self): |
186 | 186 | """DateTimeField.to_python should support usecs""" |
187 | 187 | f = models.DateTimeField() |
188 | 188 | self.assertEqual(f.to_python('2001-01-02 03:04:05.000006'), |
… |
… |
class DateTimeFieldTests(unittest.TestCase):
|
190 | 190 | self.assertEqual(f.to_python('2001-01-02 03:04:05.999999'), |
191 | 191 | datetime.datetime(2001, 1, 2, 3, 4, 5, 999999)) |
192 | 192 | |
193 | | def test_timefield_to_python_usecs(self): |
| 193 | def test_TimeField_to_python_usecs(self): |
194 | 194 | """TimeField.to_python should support usecs""" |
195 | 195 | f = models.TimeField() |
196 | 196 | self.assertEqual(f.to_python('01:02:03.000004'), |
… |
… |
class DateTimeFieldTests(unittest.TestCase):
|
212 | 212 | |
213 | 213 | |
214 | 214 | class BooleanFieldTests(unittest.TestCase): |
215 | | def _test_get_db_prep_lookup(self, f): |
| 215 | def test_get_db_prep_lookup(self, f): |
216 | 216 | self.assertEqual(f.get_db_prep_lookup('exact', True, connection=connection), [True]) |
217 | 217 | self.assertEqual(f.get_db_prep_lookup('exact', '1', connection=connection), [True]) |
218 | 218 | self.assertEqual(f.get_db_prep_lookup('exact', 1, connection=connection), [True]) |
… |
… |
class BooleanFieldTests(unittest.TestCase):
|
221 | 221 | self.assertEqual(f.get_db_prep_lookup('exact', 0, connection=connection), [False]) |
222 | 222 | self.assertEqual(f.get_db_prep_lookup('exact', None, connection=connection), [None]) |
223 | 223 | |
224 | | def _test_to_python(self, f): |
| 224 | def test_to_python(self, f): |
225 | 225 | self.assertTrue(f.to_python(1) is True) |
226 | 226 | self.assertTrue(f.to_python(0) is False) |
227 | 227 | |
228 | | def test_booleanfield_get_db_prep_lookup(self): |
| 228 | def test_BooleanField_get_db_prep_lookup(self): |
229 | 229 | self._test_get_db_prep_lookup(models.BooleanField()) |
230 | 230 | |
231 | | def test_nullbooleanfield_get_db_prep_lookup(self): |
| 231 | def test_NullBooleanField_get_db_prep_lookup(self): |
232 | 232 | self._test_get_db_prep_lookup(models.NullBooleanField()) |
233 | 233 | |
234 | | def test_booleanfield_to_python(self): |
| 234 | def test_BooleanField_to_python(self): |
235 | 235 | self._test_to_python(models.BooleanField()) |
236 | 236 | |
237 | | def test_nullbooleanfield_to_python(self): |
| 237 | def test_NullBooleanField_to_python(self): |
238 | 238 | self._test_to_python(models.NullBooleanField()) |
239 | 239 | |
240 | | def test_charfield_textfield_max_length_passed_to_formfield(self): |
| 240 | def test_CharField_TextField_max_length_passed_to_formfield(self): |
241 | 241 | """ |
242 | 242 | Test that CharField and TextField pass their max_length attributes to |
243 | 243 | form fields created using their .formfield() method (#22206). |
… |
… |
class BooleanFieldTests(unittest.TestCase):
|
252 | 252 | self.assertIsNone(tf1.formfield().max_length) |
253 | 253 | self.assertEqual(2345, tf2.formfield().max_length) |
254 | 254 | |
255 | | def test_booleanfield_choices_blank(self): |
| 255 | def test_BooleanField_choices_blank(self): |
256 | 256 | """ |
257 | 257 | Test that BooleanField with choices and defaults doesn't generate a |
258 | 258 | formfield with the blank option (#9640, #10549). |
… |
… |
class ChoicesTests(test.TestCase):
|
377 | 377 | |
378 | 378 | |
379 | 379 | class SlugFieldTests(test.TestCase): |
380 | | def test_slugfield_max_length(self): |
| 380 | def test_SlugField_max_length(self): |
381 | 381 | """ |
382 | 382 | Make sure SlugField honors max_length (#9706) |
383 | 383 | """ |
… |
… |
class SlugFieldTests(test.TestCase):
|
387 | 387 | |
388 | 388 | |
389 | 389 | class ValidationTest(test.TestCase): |
390 | | def test_charfield_raises_error_on_empty_string(self): |
| 390 | def test_CharField_raises_error_on_empty_string(self): |
391 | 391 | f = models.CharField() |
392 | 392 | self.assertRaises(ValidationError, f.clean, "", None) |
393 | 393 | |
394 | | def test_charfield_cleans_empty_string_when_blank_true(self): |
| 394 | def test_CharField_cleans_empty_string_when_blank_true(self): |
395 | 395 | f = models.CharField(blank=True) |
396 | 396 | self.assertEqual('', f.clean('', None)) |
397 | 397 | |
398 | | def test_integerfield_cleans_valid_string(self): |
| 398 | def test_IntegerField_cleans_valid_string(self): |
399 | 399 | f = models.IntegerField() |
400 | 400 | self.assertEqual(2, f.clean('2', None)) |
401 | 401 | |
402 | | def test_integerfield_raises_error_on_invalid_intput(self): |
| 402 | def test_IntegerField_raises_error_on_invalid_intput(self): |
403 | 403 | f = models.IntegerField() |
404 | 404 | self.assertRaises(ValidationError, f.clean, "a", None) |
405 | 405 | |
406 | | def test_charfield_with_choices_cleans_valid_choice(self): |
| 406 | def test_CharField_with_choices_cleans_valid_choice(self): |
407 | 407 | f = models.CharField(max_length=1, |
408 | 408 | choices=[('a', 'A'), ('b', 'B')]) |
409 | 409 | self.assertEqual('a', f.clean('a', None)) |
410 | 410 | |
411 | | def test_charfield_with_choices_raises_error_on_invalid_choice(self): |
| 411 | def test_CharField_with_choices_raises_error_on_invalid_choice(self): |
412 | 412 | f = models.CharField(choices=[('a', 'A'), ('b', 'B')]) |
413 | 413 | self.assertRaises(ValidationError, f.clean, "not a", None) |
414 | 414 | |
415 | | def test_charfield_get_choices_with_blank_defined(self): |
| 415 | def test_CharField_get_choices_with_blank_defined(self): |
416 | 416 | f = models.CharField(choices=[('', '<><>'), ('a', 'A')]) |
417 | 417 | self.assertEqual(f.get_choices(True), [('', '<><>'), ('a', 'A')]) |
418 | 418 | |
… |
… |
class ValidationTest(test.TestCase):
|
421 | 421 | choices=(('group', ((10, 'A'), (20, 'B'))), (30, 'C'))) |
422 | 422 | self.assertEqual(10, f.clean(10, None)) |
423 | 423 | |
424 | | def test_nullable_integerfield_raises_error_with_blank_false(self): |
| 424 | def test_nullable_IntegerField_raises_error_with_blank_false(self): |
425 | 425 | f = models.IntegerField(null=True, blank=False) |
426 | 426 | self.assertRaises(ValidationError, f.clean, None, None) |
427 | 427 | |
428 | | def test_nullable_integerfield_cleans_none_on_null_and_blank_true(self): |
| 428 | def test_nullable_IntegerField_cleans_none_on_null_and_blank_true(self): |
429 | 429 | f = models.IntegerField(null=True, blank=True) |
430 | 430 | self.assertEqual(None, f.clean(None, None)) |
431 | 431 | |
432 | | def test_integerfield_raises_error_on_empty_input(self): |
| 432 | def test_IntegerField_raises_error_on_empty_input(self): |
433 | 433 | f = models.IntegerField(null=False) |
434 | 434 | self.assertRaises(ValidationError, f.clean, None, None) |
435 | 435 | self.assertRaises(ValidationError, f.clean, '', None) |
436 | 436 | |
437 | | def test_integerfield_validates_zero_against_choices(self): |
| 437 | def test_IntegerField_validates_zero_against_choices(self): |
438 | 438 | f = models.IntegerField(choices=((1, 1),)) |
439 | 439 | self.assertRaises(ValidationError, f.clean, '0', None) |
440 | 440 | |
441 | | def test_charfield_raises_error_on_empty_input(self): |
| 441 | def test_CharField_raises_error_on_empty_input(self): |
442 | 442 | f = models.CharField(null=False) |
443 | 443 | self.assertRaises(ValidationError, f.clean, None, None) |
444 | 444 | |
445 | | def test_datefield_cleans_date(self): |
| 445 | def test_DateField_cleans_date(self): |
446 | 446 | f = models.DateField() |
447 | 447 | self.assertEqual(datetime.date(2008, 10, 10), f.clean('2008-10-10', None)) |
448 | 448 | |
449 | | def test_boolean_field_doesnt_accept_empty_input(self): |
| 449 | def test_BooleanField_does_not_accept_empty_input(self): |
450 | 450 | f = models.BooleanField() |
451 | 451 | self.assertRaises(ValidationError, f.clean, None, None) |
452 | 452 | |
… |
… |
class TypeCoercionTests(test.TestCase):
|
546 | 546 | automatic casting at the DB level. See #10015. |
547 | 547 | |
548 | 548 | """ |
549 | | def test_lookup_integer_in_charfield(self): |
| 549 | def test_lookup_integer_in_CharField(self): |
550 | 550 | self.assertEqual(Post.objects.filter(title=9).count(), 0) |
551 | 551 | |
552 | | def test_lookup_integer_in_textfield(self): |
| 552 | def test_lookup_integer_in_TextField(self): |
553 | 553 | self.assertEqual(Post.objects.filter(body=24).count(), 0) |
554 | 554 | |
555 | 555 | |
… |
… |
class BinaryFieldTests(test.TestCase):
|
626 | 626 | |
627 | 627 | |
628 | 628 | class GenericIPAddressFieldTests(test.TestCase): |
629 | | def test_genericipaddressfield_formfield_protocol(self): |
| 629 | def test_GenericIPAddressField_formfield_protocol(self): |
630 | 630 | """ |
631 | 631 | Test that GenericIPAddressField with a specified protocol does not |
632 | 632 | generate a formfield with no specified protocol. See #20740. |
-
--
1.9.1
From bf34e6190df549374cfec224e6ab91583bbefe6e Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 16:54:11 +0300
Subject: [PATCH 09/12] Changed camel case test names.
---
tests/nested_foreign_keys/tests.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/nested_foreign_keys/tests.py b/tests/nested_foreign_keys/tests.py
index faf9f60..e08922a 100644
a
|
b
|
class NestedForeignKeysTests(TestCase):
|
31 | 31 | |
32 | 32 | # This test failed in #16715 because in some cases INNER JOIN was selected |
33 | 33 | # for the second foreign key relation instead of LEFT OUTER JOIN. |
34 | | def testInheritance(self): |
| 34 | def test_inheritance(self): |
35 | 35 | Event.objects.create() |
36 | 36 | Screening.objects.create(movie=self.movie) |
37 | 37 | |
… |
… |
class NestedForeignKeysTests(TestCase):
|
52 | 52 | self.assertEqual(Event.objects.exclude(screening__movie=self.movie).count(), 1) |
53 | 53 | |
54 | 54 | # These all work because the second foreign key in the chain has null=True. |
55 | | def testInheritanceNullFK(self): |
| 55 | def test_inheritance_null_FK(self): |
56 | 56 | Event.objects.create() |
57 | 57 | ScreeningNullFK.objects.create(movie=None) |
58 | 58 | ScreeningNullFK.objects.create(movie=self.movie) |
… |
… |
class NestedForeignKeysTests(TestCase):
|
79 | 79 | |
80 | 80 | # This test failed in #16715 because in some cases INNER JOIN was selected |
81 | 81 | # for the second foreign key relation instead of LEFT OUTER JOIN. |
82 | | def testExplicitForeignKey(self): |
| 82 | def test_explicit_ForeignKey(self): |
83 | 83 | Package.objects.create() |
84 | 84 | screening = Screening.objects.create(movie=self.movie) |
85 | 85 | Package.objects.create(screening=screening) |
… |
… |
class NestedForeignKeysTests(TestCase):
|
99 | 99 | self.assertEqual(Package.objects.exclude(screening__movie=self.movie).count(), 1) |
100 | 100 | |
101 | 101 | # These all work because the second foreign key in the chain has null=True. |
102 | | def testExplicitForeignKeyNullFK(self): |
| 102 | def test_explicit_ForeignKey_NullFK(self): |
103 | 103 | PackageNullFK.objects.create() |
104 | 104 | screening = ScreeningNullFK.objects.create(movie=None) |
105 | 105 | screening_with_movie = ScreeningNullFK.objects.create(movie=self.movie) |
… |
… |
class DeeplyNestedForeignKeysTests(TestCase):
|
128 | 128 | self.director = Person.objects.create(name='Terry Gilliam / Terry Jones') |
129 | 129 | self.movie = Movie.objects.create(title='Monty Python and the Holy Grail', director=self.director) |
130 | 130 | |
131 | | def testInheritance(self): |
| 131 | def test_inheritance(self): |
132 | 132 | Event.objects.create() |
133 | 133 | Screening.objects.create(movie=self.movie) |
134 | 134 | |
… |
… |
class DeeplyNestedForeignKeysTests(TestCase):
|
147 | 147 | self.assertEqual(Event.objects.filter(screening__movie__director=self.director).count(), 1) |
148 | 148 | self.assertEqual(Event.objects.exclude(screening__movie__director=self.director).count(), 1) |
149 | 149 | |
150 | | def testExplicitForeignKey(self): |
| 150 | def test_explicit_ForeignKey(self): |
151 | 151 | Package.objects.create() |
152 | 152 | screening = Screening.objects.create(movie=self.movie) |
153 | 153 | Package.objects.create(screening=screening) |
-
--
1.9.1
From f12558b8b9db7f8a43f018c7735ade57ebaf2930 Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 17:01:28 +0300
Subject: [PATCH 10/12] Modified camel case test names.
---
tests/raw_query/tests.py | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/tests/raw_query/tests.py b/tests/raw_query/tests.py
index 17479df..80372c1 100644
a
|
b
|
class RawQueryTests(TestCase):
|
59 | 59 | self.assertTrue(hasattr(result, annotation)) |
60 | 60 | self.assertEqual(getattr(result, annotation), value) |
61 | 61 | |
62 | | def testSimpleRawQuery(self): |
| 62 | def test_simple_raw_query(self): |
63 | 63 | """ |
64 | 64 | Basic test of raw query with a simple database query |
65 | 65 | """ |
… |
… |
class RawQueryTests(TestCase):
|
67 | 67 | authors = Author.objects.all() |
68 | 68 | self.assertSuccessfulRawQuery(Author, query, authors) |
69 | 69 | |
70 | | def testRawQueryLazy(self): |
| 70 | def test_raw_query_lazy(self): |
71 | 71 | """ |
72 | 72 | Raw queries are lazy: they aren't actually executed until they're |
73 | 73 | iterated over. |
… |
… |
class RawQueryTests(TestCase):
|
77 | 77 | list(q) |
78 | 78 | self.assertTrue(q.query.cursor is not None) |
79 | 79 | |
80 | | def testFkeyRawQuery(self): |
| 80 | def test_FK_raw_query(self): |
81 | 81 | """ |
82 | 82 | Test of a simple raw query against a model containing a foreign key |
83 | 83 | """ |
… |
… |
class RawQueryTests(TestCase):
|
85 | 85 | books = Book.objects.all() |
86 | 86 | self.assertSuccessfulRawQuery(Book, query, books) |
87 | 87 | |
88 | | def testDBColumnHandler(self): |
| 88 | def test_db_column_handler(self): |
89 | 89 | """ |
90 | 90 | Test of a simple raw query against a model containing a field with |
91 | 91 | db_column defined. |
… |
… |
class RawQueryTests(TestCase):
|
94 | 94 | coffees = Coffee.objects.all() |
95 | 95 | self.assertSuccessfulRawQuery(Coffee, query, coffees) |
96 | 96 | |
97 | | def testOrderHandler(self): |
| 97 | def test_order_handler(self): |
98 | 98 | """ |
99 | 99 | Test of raw raw query's tolerance for columns being returned in any |
100 | 100 | order |
… |
… |
class RawQueryTests(TestCase):
|
110 | 110 | authors = Author.objects.all() |
111 | 111 | self.assertSuccessfulRawQuery(Author, query, authors) |
112 | 112 | |
113 | | def testTranslations(self): |
| 113 | def test_translations(self): |
114 | 114 | """ |
115 | 115 | Test of raw query's optional ability to translate unexpected result |
116 | 116 | column names to specific model fields |
… |
… |
class RawQueryTests(TestCase):
|
120 | 120 | authors = Author.objects.all() |
121 | 121 | self.assertSuccessfulRawQuery(Author, query, authors, translations=translations) |
122 | 122 | |
123 | | def testParams(self): |
| 123 | def test_params(self): |
124 | 124 | """ |
125 | 125 | Test passing optional query parameters |
126 | 126 | """ |
… |
… |
class RawQueryTests(TestCase):
|
135 | 135 | self.assertIsInstance(repr(qset), str) |
136 | 136 | |
137 | 137 | @skipUnlessDBFeature('supports_paramstyle_pyformat') |
138 | | def testPyformatParams(self): |
| 138 | def test_pyformat_params(self): |
139 | 139 | """ |
140 | 140 | Test passing optional query parameters |
141 | 141 | """ |
… |
… |
class RawQueryTests(TestCase):
|
149 | 149 | self.assertEqual(len(results), 1) |
150 | 150 | self.assertIsInstance(repr(qset), str) |
151 | 151 | |
152 | | def testManyToMany(self): |
| 152 | def test_many_to_many(self): |
153 | 153 | """ |
154 | 154 | Test of a simple raw query against a model containing a m2m field |
155 | 155 | """ |
… |
… |
class RawQueryTests(TestCase):
|
157 | 157 | reviewers = Reviewer.objects.all() |
158 | 158 | self.assertSuccessfulRawQuery(Reviewer, query, reviewers) |
159 | 159 | |
160 | | def testExtraConversions(self): |
| 160 | def test_extra_conversions(self): |
161 | 161 | """ |
162 | 162 | Test to insure that extra translations are ignored. |
163 | 163 | """ |
… |
… |
class RawQueryTests(TestCase):
|
166 | 166 | authors = Author.objects.all() |
167 | 167 | self.assertSuccessfulRawQuery(Author, query, authors, translations=translations) |
168 | 168 | |
169 | | def testMissingFields(self): |
| 169 | def test_missing_fields(self): |
170 | 170 | query = "SELECT id, first_name, dob FROM raw_query_author" |
171 | 171 | for author in Author.objects.raw(query): |
172 | 172 | self.assertNotEqual(author.first_name, None) |
173 | 173 | # last_name isn't given, but it will be retrieved on demand |
174 | 174 | self.assertNotEqual(author.last_name, None) |
175 | 175 | |
176 | | def testMissingFieldsWithoutPK(self): |
| 176 | def test_missing_fields_without_PK(self): |
177 | 177 | query = "SELECT first_name, dob FROM raw_query_author" |
178 | 178 | try: |
179 | 179 | list(Author.objects.raw(query)) |
… |
… |
class RawQueryTests(TestCase):
|
181 | 181 | except InvalidQuery: |
182 | 182 | pass |
183 | 183 | |
184 | | def testAnnotations(self): |
| 184 | def test_annotations(self): |
185 | 185 | query = "SELECT a.*, count(b.id) as book_count FROM raw_query_author a LEFT JOIN raw_query_book b ON a.id = b.author_id GROUP BY a.id, a.first_name, a.last_name, a.dob ORDER BY a.id" |
186 | 186 | expected_annotations = ( |
187 | 187 | ('book_count', 3), |
… |
… |
class RawQueryTests(TestCase):
|
192 | 192 | authors = Author.objects.all() |
193 | 193 | self.assertSuccessfulRawQuery(Author, query, authors, expected_annotations) |
194 | 194 | |
195 | | def testWhiteSpaceQuery(self): |
| 195 | def test_white_space_query(self): |
196 | 196 | query = " SELECT * FROM raw_query_author" |
197 | 197 | authors = Author.objects.all() |
198 | 198 | self.assertSuccessfulRawQuery(Author, query, authors) |
199 | 199 | |
200 | | def testMultipleIterations(self): |
| 200 | def test_multiple_iterations(self): |
201 | 201 | query = "SELECT * FROM raw_query_author" |
202 | 202 | normal_authors = Author.objects.all() |
203 | 203 | raw_authors = Author.objects.raw(query) |
… |
… |
class RawQueryTests(TestCase):
|
216 | 216 | |
217 | 217 | self.assertEqual(first_iterations, second_iterations) |
218 | 218 | |
219 | | def testGetItem(self): |
| 219 | def test_get_item(self): |
220 | 220 | # Indexing on RawQuerySets |
221 | 221 | query = "SELECT * FROM raw_query_author ORDER BY id ASC" |
222 | 222 | third_author = Author.objects.raw(query)[2] |
-
--
1.9.1
From fa19d6014682fcd01f6014244f31685d02556900 Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 17:57:04 +0300
Subject: [PATCH 11/12] Modified camel case test names.
---
tests/utils_tests/test_http.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py
index eec439a..3f512ad 100644
a
|
b
|
class TestUtilsHttp(unittest.TestCase):
|
121 | 121 | |
122 | 122 | |
123 | 123 | class ETagProcessingTests(unittest.TestCase): |
124 | | def testParsing(self): |
| 124 | def test_parsing(self): |
125 | 125 | etags = http.parse_etags(r'"", "etag", "e\"t\"ag", "e\\tag", W/"weak"') |
126 | 126 | self.assertEqual(etags, ['', 'etag', 'e"t"ag', r'e\tag', 'weak']) |
127 | 127 | |
128 | | def testQuoting(self): |
| 128 | def test_quoting(self): |
129 | 129 | quoted_etag = http.quote_etag(r'e\t"ag') |
130 | 130 | self.assertEqual(quoted_etag, r'"e\\t\"ag"') |
131 | 131 | |
132 | 132 | |
133 | 133 | class HttpDateProcessingTests(unittest.TestCase): |
134 | | def testParsingRfc1123(self): |
| 134 | def test_parsing_rfc1123(self): |
135 | 135 | parsed = http.parse_http_date('Sun, 06 Nov 1994 08:49:37 GMT') |
136 | 136 | self.assertEqual(datetime.utcfromtimestamp(parsed), |
137 | 137 | datetime(1994, 11, 6, 8, 49, 37)) |
138 | 138 | |
139 | | def testParsingRfc850(self): |
| 139 | def test_parsing_rfc850(self): |
140 | 140 | parsed = http.parse_http_date('Sunday, 06-Nov-94 08:49:37 GMT') |
141 | 141 | self.assertEqual(datetime.utcfromtimestamp(parsed), |
142 | 142 | datetime(1994, 11, 6, 8, 49, 37)) |
143 | 143 | |
144 | | def testParsingAsctime(self): |
| 144 | def test_parsing_asctime(self): |
145 | 145 | parsed = http.parse_http_date('Sun Nov 6 08:49:37 1994') |
146 | 146 | self.assertEqual(datetime.utcfromtimestamp(parsed), |
147 | 147 | datetime(1994, 11, 6, 8, 49, 37)) |
-
--
1.9.1
From bdbcc5090719bfd9e57ef2f1ff7925e3dbed3a9c Mon Sep 17 00:00:00 2001
From: Brylie Christopher Oxley <brylie@gnumedia.org>
Date: Mon, 30 Jun 2014 18:06:59 +0300
Subject: [PATCH 12/12] Modified camel case test names.
---
tests/view_tests/tests/test_i18n.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py
index 8798c0d..a40491c 100644
a
|
b
|
class JsI18NTests(TestCase):
|
115 | 115 | response = self.client.get('/jsi18n/') |
116 | 116 | self.assertContains(response, 'il faut le traduire') |
117 | 117 | |
118 | | def testI18NLanguageNonEnglishDefault(self): |
| 118 | def test_i18n_language_non_english_default(self): |
119 | 119 | """ |
120 | 120 | Check if the Javascript i18n view returns an empty language catalog |
121 | 121 | if the default language is non-English, the selected language |
… |
… |
class JsI18NTests(TestCase):
|
127 | 127 | self.assertNotContains(response, 'Choisir une heure') |
128 | 128 | |
129 | 129 | @modify_settings(INSTALLED_APPS={'append': 'view_tests.app0'}) |
130 | | def test_nonenglish_default_english_userpref(self): |
| 130 | def test_non_english_default_english_userpref(self): |
131 | 131 | """ |
132 | 132 | Same as above with the difference that there IS an 'en' translation |
133 | 133 | available. The Javascript i18n view must return a NON empty language catalog |
… |
… |
class JsI18NTests(TestCase):
|
137 | 137 | response = self.client.get('/jsi18n_english_translation/') |
138 | 138 | self.assertContains(response, 'this app0 string is to be translated') |
139 | 139 | |
140 | | def testI18NLanguageNonEnglishFallback(self): |
| 140 | def test_i18n_language_non_english_fallback(self): |
141 | 141 | """ |
142 | 142 | Makes sure that the fallback language is still working properly |
143 | 143 | in cases where the selected language cannot be found. |
… |
… |
class JsI18NTestsMultiPackage(TestCase):
|
170 | 170 | settings.LANGUAGE_CODE and merge JS translation from several packages. |
171 | 171 | """ |
172 | 172 | @modify_settings(INSTALLED_APPS={'append': ['view_tests.app1', 'view_tests.app2']}) |
173 | | def testI18NLanguageEnglishDefault(self): |
| 173 | def test_i18n_language_english_default(self): |
174 | 174 | """ |
175 | 175 | Check if the JavaScript i18n view returns a complete language catalog |
176 | 176 | if the default language is en-us, the selected language has a |
… |
… |
class JsI18NTestsMultiPackage(TestCase):
|
183 | 183 | self.assertContains(response, 'il faut traduire cette cha\\u00eene de caract\\u00e8res de app1') |
184 | 184 | |
185 | 185 | @modify_settings(INSTALLED_APPS={'append': ['view_tests.app3', 'view_tests.app4']}) |
186 | | def testI18NDifferentNonEnLangs(self): |
| 186 | def test_i18n_different_non_english_languages(self): |
187 | 187 | """ |
188 | 188 | Similar to above but with neither default or requested language being |
189 | 189 | English. |
… |
… |
class JsI18NTestsMultiPackage(TestCase):
|
192 | 192 | response = self.client.get('/jsi18n_multi_packages2/') |
193 | 193 | self.assertContains(response, 'este texto de app3 debe ser traducido') |
194 | 194 | |
195 | | def testI18NWithLocalePaths(self): |
| 195 | def test_i18n_with_locale_paths(self): |
196 | 196 | extended_locale_paths = settings.LOCALE_PATHS + ( |
197 | 197 | path.join(path.dirname( |
198 | 198 | path.dirname(path.abspath(upath(__file__)))), 'app3', 'locale'),) |