Loading tests/admin_custom_urls/models.py +4 −3 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ class CarAdmin(admin.ModelAdmin): request, obj, post_url_continue=reverse('admin:admin_custom_urls_car_history', args=[obj.pk])) admin.site.register(Action, ActionAdmin) admin.site.register(Person, PersonAdmin) admin.site.register(Car, CarAdmin) site = admin.AdminSite(name='admin_custom_urls') site.register(Action, ActionAdmin) site.register(Person, PersonAdmin) site.register(Car, CarAdmin) tests/admin_custom_urls/tests.py +11 −11 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ class AdminCustomUrlsTest(TestCase): """ Ensure GET on the add_view works. """ add_url = reverse('admin:admin_custom_urls_action_add') add_url = reverse('admin_custom_urls:admin_custom_urls_action_add') self.assertTrue(add_url.endswith('/!add/')) response = self.client.get(add_url) self.assertIsInstance(response, TemplateResponse) Loading @@ -61,7 +61,7 @@ class AdminCustomUrlsTest(TestCase): Ensure GET on the add_view plus specifying a field value in the query string works. """ response = self.client.get(reverse('admin:admin_custom_urls_action_add'), {'name': 'My Action'}) response = self.client.get(reverse('admin_custom_urls:admin_custom_urls_action_add'), {'name': 'My Action'}) self.assertEqual(response.status_code, 200) self.assertContains(response, 'value="My Action"') Loading @@ -74,7 +74,7 @@ class AdminCustomUrlsTest(TestCase): "name": 'Action added through a popup', "description": "Description of added action", } response = self.client.post(reverse('admin:admin_custom_urls_action_add'), post_data) response = self.client.post(reverse('admin_custom_urls:admin_custom_urls_action_add'), post_data) self.assertEqual(response.status_code, 200) self.assertContains(response, 'dismissAddRelatedObjectPopup') self.assertContains(response, 'Action added through a popup') Loading @@ -85,7 +85,7 @@ class AdminCustomUrlsTest(TestCase): """ # Should get the change_view for model instance with PK 'add', not show # the add_view url = reverse('admin:%s_action_change' % Action._meta.app_label, url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label, args=(quote('add'),)) response = self.client.get(url) self.assertEqual(response.status_code, 200) Loading @@ -93,7 +93,7 @@ class AdminCustomUrlsTest(TestCase): # Should correctly get the change_view for the model instance with the # funny-looking PK (the one with a 'path/to/html/document.html' value) url = reverse('admin:%s_action_change' % Action._meta.app_label, url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label, args=(quote("path/to/html/document.html"),)) response = self.client.get(url) self.assertEqual(response.status_code, 200) Loading @@ -110,11 +110,11 @@ class AdminCustomUrlsTest(TestCase): post_data = {'name': 'John Doe'} self.assertEqual(Person.objects.count(), 0) response = self.client.post( reverse('admin:admin_custom_urls_person_add'), post_data) reverse('admin_custom_urls:admin_custom_urls_person_add'), post_data) persons = Person.objects.all() self.assertEqual(len(persons), 1) self.assertRedirects( response, reverse('admin:admin_custom_urls_person_history', args=[persons[0].pk])) response, reverse('admin_custom_urls:admin_custom_urls_person_history', args=[persons[0].pk])) def test_post_save_change_redirect(self): """ Loading @@ -128,9 +128,9 @@ class AdminCustomUrlsTest(TestCase): person = Person.objects.all()[0] post_data = {'name': 'Jack Doe'} response = self.client.post( reverse('admin:admin_custom_urls_person_change', args=[person.pk]), post_data) reverse('admin_custom_urls:admin_custom_urls_person_change', args=[person.pk]), post_data) self.assertRedirects( response, reverse('admin:admin_custom_urls_person_delete', args=[person.pk])) response, reverse('admin_custom_urls:admin_custom_urls_person_delete', args=[person.pk])) def test_post_url_continue(self): """ Loading @@ -140,8 +140,8 @@ class AdminCustomUrlsTest(TestCase): post_data = {'name': 'SuperFast', '_continue': '1'} self.assertEqual(Car.objects.count(), 0) response = self.client.post( reverse('admin:admin_custom_urls_car_add'), post_data) reverse('admin_custom_urls:admin_custom_urls_car_add'), post_data) cars = Car.objects.all() self.assertEqual(len(cars), 1) self.assertRedirects( response, reverse('admin:admin_custom_urls_car_history', args=[cars[0].pk])) response, reverse('admin_custom_urls:admin_custom_urls_car_history', args=[cars[0].pk])) tests/admin_custom_urls/urls.py +3 −2 Original line number Diff line number Diff line from django.conf.urls import include, url from django.contrib import admin from .models import site urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(site.urls)), ] tests/gis_tests/geoadmin/models.py +2 −1 Original line number Diff line number Diff line Loading @@ -16,4 +16,5 @@ class City(models.Model): def __str__(self): return self.name admin.site.register(City, admin.OSMGeoAdmin) site = admin.AdminSite(name='admin_gis') site.register(City, admin.OSMGeoAdmin) tests/gis_tests/geoadmin/tests.py +10 −10 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ if HAS_GEOS: from django.contrib.gis.geos import Point from .admin import UnmodifiableAdmin from .models import City from .models import site, City @skipUnlessDBFeature("gis_enabled") Loading @@ -16,14 +16,14 @@ if HAS_GEOS: class GeoAdminTest(TestCase): def test_ensure_geographic_media(self): geoadmin = admin.site._registry[City] geoadmin = site._registry[City] admin_js = geoadmin.media.render_js() self.assertTrue(any(geoadmin.openlayers_url in js for js in admin_js)) def test_olmap_OSM_rendering(self): delete_all_btn = """<a href="javascript:geodjango_point.clearFeatures()">Delete all Features</a>""" original_geoadmin = admin.site._registry[City] original_geoadmin = site._registry[City] params = original_geoadmin.get_map_widget(City._meta.get_field('point')).params result = original_geoadmin.get_map_widget(City._meta.get_field('point'))( ).render('point', Point(-79.460734, 40.18476), params) Loading @@ -33,21 +33,21 @@ class GeoAdminTest(TestCase): self.assertIn(delete_all_btn, result) admin.site.unregister(City) admin.site.register(City, UnmodifiableAdmin) site.unregister(City) site.register(City, UnmodifiableAdmin) try: geoadmin = admin.site._registry[City] geoadmin = site._registry[City] params = geoadmin.get_map_widget(City._meta.get_field('point')).params result = geoadmin.get_map_widget(City._meta.get_field('point'))( ).render('point', Point(-79.460734, 40.18476), params) self.assertNotIn(delete_all_btn, result) finally: admin.site.unregister(City) admin.site.register(City, original_geoadmin.__class__) site.unregister(City) site.register(City, original_geoadmin.__class__) def test_olmap_WMS_rendering(self): geoadmin = admin.GeoModelAdmin(City, admin.site) geoadmin = admin.GeoModelAdmin(City, site) result = geoadmin.get_map_widget(City._meta.get_field('point'))( ).render('point', Point(-79.460734, 40.18476)) self.assertIn( Loading @@ -59,7 +59,7 @@ class GeoAdminTest(TestCase): """ Check that changes are accurately noticed by OpenLayersWidget. """ geoadmin = admin.site._registry[City] geoadmin = site._registry[City] form = geoadmin.get_changelist_form(None)() has_changed = form.fields['point'].has_changed Loading Loading
tests/admin_custom_urls/models.py +4 −3 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ class CarAdmin(admin.ModelAdmin): request, obj, post_url_continue=reverse('admin:admin_custom_urls_car_history', args=[obj.pk])) admin.site.register(Action, ActionAdmin) admin.site.register(Person, PersonAdmin) admin.site.register(Car, CarAdmin) site = admin.AdminSite(name='admin_custom_urls') site.register(Action, ActionAdmin) site.register(Person, PersonAdmin) site.register(Car, CarAdmin)
tests/admin_custom_urls/tests.py +11 −11 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ class AdminCustomUrlsTest(TestCase): """ Ensure GET on the add_view works. """ add_url = reverse('admin:admin_custom_urls_action_add') add_url = reverse('admin_custom_urls:admin_custom_urls_action_add') self.assertTrue(add_url.endswith('/!add/')) response = self.client.get(add_url) self.assertIsInstance(response, TemplateResponse) Loading @@ -61,7 +61,7 @@ class AdminCustomUrlsTest(TestCase): Ensure GET on the add_view plus specifying a field value in the query string works. """ response = self.client.get(reverse('admin:admin_custom_urls_action_add'), {'name': 'My Action'}) response = self.client.get(reverse('admin_custom_urls:admin_custom_urls_action_add'), {'name': 'My Action'}) self.assertEqual(response.status_code, 200) self.assertContains(response, 'value="My Action"') Loading @@ -74,7 +74,7 @@ class AdminCustomUrlsTest(TestCase): "name": 'Action added through a popup', "description": "Description of added action", } response = self.client.post(reverse('admin:admin_custom_urls_action_add'), post_data) response = self.client.post(reverse('admin_custom_urls:admin_custom_urls_action_add'), post_data) self.assertEqual(response.status_code, 200) self.assertContains(response, 'dismissAddRelatedObjectPopup') self.assertContains(response, 'Action added through a popup') Loading @@ -85,7 +85,7 @@ class AdminCustomUrlsTest(TestCase): """ # Should get the change_view for model instance with PK 'add', not show # the add_view url = reverse('admin:%s_action_change' % Action._meta.app_label, url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label, args=(quote('add'),)) response = self.client.get(url) self.assertEqual(response.status_code, 200) Loading @@ -93,7 +93,7 @@ class AdminCustomUrlsTest(TestCase): # Should correctly get the change_view for the model instance with the # funny-looking PK (the one with a 'path/to/html/document.html' value) url = reverse('admin:%s_action_change' % Action._meta.app_label, url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label, args=(quote("path/to/html/document.html"),)) response = self.client.get(url) self.assertEqual(response.status_code, 200) Loading @@ -110,11 +110,11 @@ class AdminCustomUrlsTest(TestCase): post_data = {'name': 'John Doe'} self.assertEqual(Person.objects.count(), 0) response = self.client.post( reverse('admin:admin_custom_urls_person_add'), post_data) reverse('admin_custom_urls:admin_custom_urls_person_add'), post_data) persons = Person.objects.all() self.assertEqual(len(persons), 1) self.assertRedirects( response, reverse('admin:admin_custom_urls_person_history', args=[persons[0].pk])) response, reverse('admin_custom_urls:admin_custom_urls_person_history', args=[persons[0].pk])) def test_post_save_change_redirect(self): """ Loading @@ -128,9 +128,9 @@ class AdminCustomUrlsTest(TestCase): person = Person.objects.all()[0] post_data = {'name': 'Jack Doe'} response = self.client.post( reverse('admin:admin_custom_urls_person_change', args=[person.pk]), post_data) reverse('admin_custom_urls:admin_custom_urls_person_change', args=[person.pk]), post_data) self.assertRedirects( response, reverse('admin:admin_custom_urls_person_delete', args=[person.pk])) response, reverse('admin_custom_urls:admin_custom_urls_person_delete', args=[person.pk])) def test_post_url_continue(self): """ Loading @@ -140,8 +140,8 @@ class AdminCustomUrlsTest(TestCase): post_data = {'name': 'SuperFast', '_continue': '1'} self.assertEqual(Car.objects.count(), 0) response = self.client.post( reverse('admin:admin_custom_urls_car_add'), post_data) reverse('admin_custom_urls:admin_custom_urls_car_add'), post_data) cars = Car.objects.all() self.assertEqual(len(cars), 1) self.assertRedirects( response, reverse('admin:admin_custom_urls_car_history', args=[cars[0].pk])) response, reverse('admin_custom_urls:admin_custom_urls_car_history', args=[cars[0].pk]))
tests/admin_custom_urls/urls.py +3 −2 Original line number Diff line number Diff line from django.conf.urls import include, url from django.contrib import admin from .models import site urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(site.urls)), ]
tests/gis_tests/geoadmin/models.py +2 −1 Original line number Diff line number Diff line Loading @@ -16,4 +16,5 @@ class City(models.Model): def __str__(self): return self.name admin.site.register(City, admin.OSMGeoAdmin) site = admin.AdminSite(name='admin_gis') site.register(City, admin.OSMGeoAdmin)
tests/gis_tests/geoadmin/tests.py +10 −10 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ if HAS_GEOS: from django.contrib.gis.geos import Point from .admin import UnmodifiableAdmin from .models import City from .models import site, City @skipUnlessDBFeature("gis_enabled") Loading @@ -16,14 +16,14 @@ if HAS_GEOS: class GeoAdminTest(TestCase): def test_ensure_geographic_media(self): geoadmin = admin.site._registry[City] geoadmin = site._registry[City] admin_js = geoadmin.media.render_js() self.assertTrue(any(geoadmin.openlayers_url in js for js in admin_js)) def test_olmap_OSM_rendering(self): delete_all_btn = """<a href="javascript:geodjango_point.clearFeatures()">Delete all Features</a>""" original_geoadmin = admin.site._registry[City] original_geoadmin = site._registry[City] params = original_geoadmin.get_map_widget(City._meta.get_field('point')).params result = original_geoadmin.get_map_widget(City._meta.get_field('point'))( ).render('point', Point(-79.460734, 40.18476), params) Loading @@ -33,21 +33,21 @@ class GeoAdminTest(TestCase): self.assertIn(delete_all_btn, result) admin.site.unregister(City) admin.site.register(City, UnmodifiableAdmin) site.unregister(City) site.register(City, UnmodifiableAdmin) try: geoadmin = admin.site._registry[City] geoadmin = site._registry[City] params = geoadmin.get_map_widget(City._meta.get_field('point')).params result = geoadmin.get_map_widget(City._meta.get_field('point'))( ).render('point', Point(-79.460734, 40.18476), params) self.assertNotIn(delete_all_btn, result) finally: admin.site.unregister(City) admin.site.register(City, original_geoadmin.__class__) site.unregister(City) site.register(City, original_geoadmin.__class__) def test_olmap_WMS_rendering(self): geoadmin = admin.GeoModelAdmin(City, admin.site) geoadmin = admin.GeoModelAdmin(City, site) result = geoadmin.get_map_widget(City._meta.get_field('point'))( ).render('point', Point(-79.460734, 40.18476)) self.assertIn( Loading @@ -59,7 +59,7 @@ class GeoAdminTest(TestCase): """ Check that changes are accurately noticed by OpenLayersWidget. """ geoadmin = admin.site._registry[City] geoadmin = site._registry[City] form = geoadmin.get_changelist_form(None)() has_changed = form.fields['point'].has_changed Loading