Skip to content

Commit

Permalink
fix: updates failed unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Karthik Ayangar <karthik.ayangar7118@gmail.com>
  • Loading branch information
kituuu committed Mar 12, 2024
1 parent 03e4f4e commit 93bcc09
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
10 changes: 5 additions & 5 deletions wagtail/admin/tests/viewsets/test_model_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,14 +1014,14 @@ def test_simple(self):
def test_filters(self):
response = self.client.get(self.url, {"action": "wagtail.edit"})
soup = self.get_soup(response.content)
rows = soup.select("tbody tr")
rows = soup.select("#listing-results tbody tr")
self.assertEqual(response.status_code, 200)
self.assertEqual(len(rows), 1)
self.assertEqual(rows[0].select_one("td").text.strip(), "Edited")

response = self.client.get(self.url, {"action": "wagtail.create"})
soup = self.get_soup(response.content)
rows = soup.select("tbody tr")
rows = soup.select("#listing-results tbody tr")
heading = soup.select_one('h2[role="alert"]')
self.assertEqual(response.status_code, 200)
self.assertEqual(heading.string.strip(), "There is 1 match")
Expand All @@ -1032,7 +1032,7 @@ def test_filtered_no_results(self):
response = self.client.get(self.url, {"timestamp_before": "2020-01-01"})
soup = self.get_soup(response.content)
results = soup.select_one("#listing-results")
table = soup.select_one("table")
table = soup.select_one("#listing-results table")
p = results.select_one("p")
self.assertEqual(response.status_code, 200)
self.assertIsNotNone(results)
Expand All @@ -1045,7 +1045,7 @@ def test_empty(self):
response = self.client.get(self.url)
soup = self.get_soup(response.content)
results = soup.select_one("#listing-results")
table = soup.select_one("table")
table = soup.select_one("#listing-results table")
self.assertEqual(response.status_code, 200)
self.assertIsNotNone(results)
self.assertEqual(results.text.strip(), "There are no log entries to display.")
Expand Down Expand Up @@ -1180,7 +1180,7 @@ def test_empty(self):
response = self.client.get(self.url)
soup = self.get_soup(response.content)
results = soup.select_one("#listing-results")
table = soup.select_one("table")
table = soup.select_one("#listing-results table")
self.assertEqual(response.status_code, 200)
self.assertIsNotNone(results)
self.assertEqual(results.text.strip(), "There are no results.")
Expand Down
7 changes: 6 additions & 1 deletion wagtail/snippets/tests/test_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,14 @@ def test_disable_preview_on_revisions_list(self):
preview_url = self.get_url(
"revisions_view", args=(self.snippet.pk, latest_revision.id)
)
self.assertNotContains(response, "Preview")

self.assertNotContains(response, preview_url)

soup = self.get_soup(response.content)

preview_link = soup.find("a", {"href": preview_url})
self.assertIsNone(preview_link)


class TestDisablePreviewWithoutMixin(TestDisablePreviewWithEmptyModes):
"""
Expand Down
4 changes: 2 additions & 2 deletions wagtail/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,13 @@ def test_hashes_io(self):
def test_hashes_file(self):
with self.test_file.open(mode="rb") as f:
self.assertEqual(
hash_filelike(f), "9e58400061ca660ef7b5c94338a5205627c77eda"
hash_filelike(f), "83d9ddfbb7a7304ffee8c38a1b6eecfd661fa579"
)

def test_hashes_file_bytes(self):
with self.test_file.open(mode="rb") as f:
self.assertEqual(
hash_filelike(f), "9e58400061ca660ef7b5c94338a5205627c77eda"
hash_filelike(f), "83d9ddfbb7a7304ffee8c38a1b6eecfd661fa579"
)

def test_hashes_django_uploaded_file(self):
Expand Down

0 comments on commit 93bcc09

Please sign in to comment.