MCPcopy
hub / github.com/django/django / test_save_as_duplication

Method test_save_as_duplication

tests/admin_views/tests.py:2153–2164  ·  view source on GitHub ↗

save as' creates a new person

(self)

Source from the content-addressed store, hash-verified

2151 self.client.force_login(self.superuser)
2152
2153 def test_save_as_duplication(self):
2154 """'save as' creates a new person"""
2155 post_data = {"_saveasnew": "", "name": "John M", "gender": 1, "age": 42}
2156 response = self.client.post(
2157 reverse("admin:admin_views_person_change", args=(self.per1.pk,)), post_data
2158 )
2159 self.assertEqual(len(Person.objects.filter(name="John M")), 1)
2160 self.assertEqual(len(Person.objects.filter(id=self.per1.pk)), 1)
2161 new_person = Person.objects.latest("id")
2162 self.assertRedirects(
2163 response, reverse("admin:admin_views_person_change", args=(new_person.pk,))
2164 )
2165
2166 def test_save_as_continue_false(self):
2167 """

Callers

nothing calls this directly

Calls 5

reverseFunction · 0.90
latestMethod · 0.80
assertRedirectsMethod · 0.80
postMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected