refactored lists to have more descriptive urlpatterns; cascading changes across API, dashboard app & even FTs; restarted staging server db w. new migrations
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Disco DeDisco
2026-02-22 23:56:29 -05:00
parent 94f3120add
commit 168c877970
10 changed files with 40 additions and 66 deletions

View File

@@ -36,7 +36,7 @@ class NewListTest(TestCase):
def test_redirects_after_POST(self):
response = self.client.post("/dashboard/new_list", data={"text": "A new list item"})
new_list = List.objects.get()
self.assertRedirects(response, f"/dashboard/{new_list.id}/")
self.assertRedirects(response, f"/dashboard/list/{new_list.id}/")
# Post invalid input helper
def post_invalid_input(self):
@@ -58,12 +58,12 @@ class NewListTest(TestCase):
class ListViewTest(TestCase):
def test_uses_list_template(self):
mylist = List.objects.create()
response = self.client.get(f"/dashboard/{mylist.id}/")
response = self.client.get(f"/dashboard/list/{mylist.id}/")
self.assertTemplateUsed(response, "apps/dashboard/list.html")
def test_renders_input_form(self):
mylist = List.objects.create()
url = f"/dashboard/{mylist.id}/"
url = f"/dashboard/list/{mylist.id}/"
response = self.client.get(url)
parsed = lxml.html.fromstring(response.content)
forms = parsed.cssselect("form[method=POST]")
@@ -80,7 +80,7 @@ class ListViewTest(TestCase):
other_list = List.objects.create()
Item.objects.create(text="other list item", list=other_list)
# When/Act
response = self.client.get(f"/dashboard/{correct_list.id}/")
response = self.client.get(f"/dashboard/list/{correct_list.id}/")
# Then/Assert
self.assertContains(response, "itemey 1")
self.assertContains(response, "itemey 2")
@@ -91,7 +91,7 @@ class ListViewTest(TestCase):
correct_list = List.objects.create()
self.client.post(
f"/dashboard/{correct_list.id}/",
f"/dashboard/list/{correct_list.id}/",
data={"text": "A new item for an existing list"},
)
@@ -105,16 +105,16 @@ class ListViewTest(TestCase):
correct_list = List.objects.create()
response = self.client.post(
f"/dashboard/{correct_list.id}/",
f"/dashboard/list/{correct_list.id}/",
data={"text": "A new item for an existing list"},
)
self.assertRedirects(response, f"/dashboard/{correct_list.id}/")
self.assertRedirects(response, f"/dashboard/list/{correct_list.id}/")
# Post invalid input helper
def post_invalid_input(self):
mylist = List.objects.create()
return self.client.post(f"/dashboard/{mylist.id}/", data={"text": ""})
return self.client.post(f"/dashboard/list/{mylist.id}/", data={"text": ""})
def test_for_invalid_input_nothing_saved_to_db(self):
self.post_invalid_input()
@@ -140,7 +140,7 @@ class ListViewTest(TestCase):
Item.objects.create(list=list1, text="lorem ipsum")
response = self.client.post(
f"/dashboard/{list1.id}/",
f"/dashboard/list/{list1.id}/",
data={"text": "lorem ipsum"},
)
@@ -189,16 +189,16 @@ class ShareListTest(TestCase):
our_list = List.objects.create()
alice = User.objects.create(email="alice@example.com")
response = self.client.post(
f"/dashboard/{our_list.id}/share_list",
f"/dashboard/list/{our_list.id}/share_list",
data={"recipient": "alice@example.com"},
)
self.assertRedirects(response, f"/dashboard/{our_list.id}/")
self.assertRedirects(response, f"/dashboard/list/{our_list.id}/")
def test_post_with_email_adds_user_to_shared_with(self):
our_list = List.objects.create()
alice = User.objects.create(email="alice@example.com")
self.client.post(
f"/dashboard/{our_list.id}/share_list",
f"/dashboard/list/{our_list.id}/share_list",
data={"recipient": "alice@example.com"},
)
self.assertIn(alice, our_list.shared_with.all())
@@ -206,10 +206,10 @@ class ShareListTest(TestCase):
def test_post_with_nonexistent_email_redirects_to_list(self):
our_list = List.objects.create()
response = self.client.post(
f"/dashboard/{our_list.id}/share_list",
f"/dashboard/list/{our_list.id}/share_list",
data={"recipient": "nobody@example.com"},
)
self.assertRedirects(response, f"/dashboard/{our_list.id}/")
self.assertRedirects(response, f"/dashboard/list/{our_list.id}/")
def test_share_list_does_not_add_owner_as_recipient(self):
owner = User.objects.create(email="owner@example.com")