Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX:Fix test compatible with python 3.12 #1500

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions etna/ciim/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_test(self):

stripped_markup = format_description_markup(markup)

self.assertEquals(
self.assertEqual(
'<span><a href="/catalogue/id/C11996672/">link text</a></span>',
stripped_markup,
)
Expand All @@ -124,7 +124,7 @@ def test_no_links(self):

stripped_markup = format_description_markup(markup)

self.assertEquals("<span/>", stripped_markup)
self.assertEqual("<span/>", stripped_markup)

def test_multiple_links(self):
markup = (
Expand All @@ -136,7 +136,7 @@ def test_multiple_links(self):

stripped_markup = format_description_markup(markup)

self.assertEquals(
self.assertEqual(
(
"<span>"
'<a href="/catalogue/id/C11996672/">link text one</a>'
Expand All @@ -155,7 +155,7 @@ def test_external_link(self):

stripped_markup = format_description_markup(markup)

self.assertEquals(
self.assertEqual(
("<span>" '<a href="http://example.com/">link text one</a>' "</span>"),
stripped_markup,
)
Expand All @@ -166,7 +166,7 @@ def test_invalid_link(self):

stripped_markup = format_description_markup(markup)

self.assertEquals(
self.assertEqual(
("<span></span>"),
stripped_markup,
)
Expand Down Expand Up @@ -327,46 +327,46 @@ def test_none(self):

index = convert_sort_key_to_index(sort)

self.assertEquals(index, 0)
self.assertEqual(index, 0)

def test_empty_string(self):
sort = None

index = convert_sort_key_to_index(sort)

self.assertEquals(index, 0)
self.assertEqual(index, 0)

def test_converts_sort_key_with_leading_zero(self):
sort = "01"

index = convert_sort_key_to_index(sort)

self.assertEquals(index, 0)
self.assertEqual(index, 0)

def test_converts_sort_key_at_three_digit_boundary(self):
sort = "31000"

index = convert_sort_key_to_index(sort)

self.assertEquals(index, 999)
self.assertEqual(index, 999)

def test_converts_sort_key_at_four_digit_boundary(self):
sort = "31001"

index = convert_sort_key_to_index(sort)

self.assertEquals(index, 1000)
self.assertEqual(index, 1000)

def test_index_is_zero_for_invalid_sort_key(self):
sort = "10000"

index = convert_sort_key_to_index(sort)

self.assertEquals(index, 0)
self.assertEqual(index, 0)

def test_index_is_zero_for_non_int_sort_key(self):
sort = "NaN"

index = convert_sort_key_to_index(sort)

self.assertEquals(index, 0)
self.assertEqual(index, 0)
30 changes: 10 additions & 20 deletions etna/collections/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ def setUp(self):
root_page.add_child(instance=self.topic_explorer_index_page)

def test_no_child_pages(self):
self.assertEquals(
self.topic_explorer_index_page.topic_explorer_pages.count(), 0
)
self.assertEqual(self.topic_explorer_index_page.topic_explorer_pages.count(), 0)

def test_unpublish_page_excluded(self):
unpublished_topic_page = TopicExplorerPage(
Expand All @@ -33,9 +31,7 @@ def test_unpublish_page_excluded(self):
self.topic_explorer_index_page.add_child(instance=unpublished_topic_page)
unpublished_topic_page.unpublish()

self.assertEquals(
self.topic_explorer_index_page.topic_explorer_pages.count(), 0
)
self.assertEqual(self.topic_explorer_index_page.topic_explorer_pages.count(), 0)

@unittest.skip(
"Disabled test due to all child pages on home being private during beta."
Expand All @@ -47,19 +43,15 @@ def test_private_page_excluded(self):
self.topic_explorer_index_page.add_child(instance=private_topic_page)
PageViewRestriction.objects.create(page=private_topic_page)

self.assertEquals(
self.topic_explorer_index_page.topic_explorer_pages.count(), 0
)
self.assertEqual(self.topic_explorer_index_page.topic_explorer_pages.count(), 0)

def test_published_public_pages(self):
topic_page = TopicExplorerPage(
title="Topic Page", intro="test", teaser_text="test"
)
self.topic_explorer_index_page.add_child(instance=topic_page)

self.assertEquals(
self.topic_explorer_index_page.topic_explorer_pages.count(), 1
)
self.assertEqual(self.topic_explorer_index_page.topic_explorer_pages.count(), 1)

def test_published_time_period_pages_excluded(self):
topic_page = TimePeriodExplorerPage(
Expand All @@ -71,9 +63,7 @@ def test_published_time_period_pages_excluded(self):
)
self.topic_explorer_index_page.add_child(instance=topic_page)

self.assertEquals(
self.topic_explorer_index_page.topic_explorer_pages.count(), 0
)
self.assertEqual(self.topic_explorer_index_page.topic_explorer_pages.count(), 0)


class TestTopicExplorerPage(TestCase):
Expand Down Expand Up @@ -158,7 +148,7 @@ def setUp(self):
root_page.add_child(instance=self.time_period_explorer_index_page)

def test_no_child_pages(self):
self.assertEquals(
self.assertEqual(
self.time_period_explorer_index_page.time_period_explorer_pages.count(), 0
)

Expand All @@ -173,7 +163,7 @@ def test_unpublish_page_excluded(self):
self.time_period_explorer_index_page.add_child(instance=unpublished_topic_page)
unpublished_topic_page.unpublish()

self.assertEquals(
self.assertEqual(
self.time_period_explorer_index_page.time_period_explorer_pages.count(), 0
)

Expand All @@ -191,7 +181,7 @@ def test_private_page_excluded(self):
self.time_period_explorer_index_page.add_child(instance=private_topic_page)
PageViewRestriction.objects.create(page=private_topic_page)

self.assertEquals(
self.assertEqual(
self.time_period_explorer_index_page.time_period_explorer_pages.count(), 0
)

Expand All @@ -205,7 +195,7 @@ def test_published_public_pages(self):
)
self.time_period_explorer_index_page.add_child(instance=topic_page)

self.assertEquals(
self.assertEqual(
self.time_period_explorer_index_page.time_period_explorer_pages.count(), 1
)

Expand All @@ -215,6 +205,6 @@ def test_topic_pages_excluded(self):
)
self.time_period_explorer_index_page.add_child(instance=topic_page)

self.assertEquals(
self.assertEqual(
self.time_period_explorer_index_page.time_period_explorer_pages.count(), 0
)
4 changes: 2 additions & 2 deletions etna/core/tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_allows_request_when_setting_value_is_true_and_authenticated(self):
for url in CONDITIONALLY_PROTECTED_URLS:
with self.subTest(f"URL: {url}"):
response = self.client.get(url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)

@responses.activate
@override_settings(
Expand All @@ -83,4 +83,4 @@ def test_allows_unauthenticated_access_when_setting_value_is_false(self):
for url in CONDITIONALLY_PROTECTED_URLS:
with self.subTest(f"URL: {url}"):
response = self.client.get(url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
14 changes: 7 additions & 7 deletions etna/core/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ class TestMaintenanceMode(TestCase):
@prevent_request_warnings
def test_without_maintenance_mode_ends(self):
response = self.client.get("/")
self.assertEquals(response.status_code, 503)
self.assertEqual(response.status_code, 503)
self.assertNotIn("Retry-After", response.headers)

@prevent_request_warnings
@override_settings(MAINTENENCE_MODE_ENDS="2011-11-04T00:05:23+04:00")
def test_maintenance_mode_ends_with_timezone_info(self):
response = self.client.get("/")
self.assertEquals(response.status_code, 503)
self.assertEquals(
self.assertEqual(response.status_code, 503)
self.assertEqual(
response.headers["Retry-After"], "Thu, 03 Nov 2011 20:05:23 GMT"
)

@prevent_request_warnings
@override_settings(MAINTENENCE_MODE_ENDS="2011-11-04T00:05:23")
def test_maintenance_mode_ends_without_timezone_info(self):
response = self.client.get("/")
self.assertEquals(response.status_code, 503)
self.assertEquals(
self.assertEqual(response.status_code, 503)
self.assertEqual(
response.headers["Retry-After"], "Fri, 04 Nov 2011 00:05:23 GMT"
)

Expand All @@ -40,7 +40,7 @@ def test_maintenance_mode_ends_without_timezone_info(self):
def test_maintenance_mode_bypassed_when_ip_in_allow_list(self, *args):
response = self.client.get("/")

self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)

@prevent_request_warnings
@override_settings(MAINTENENCE_MODE_ALLOW_IPS=["123.4.5.6"])
Expand All @@ -49,7 +49,7 @@ def test_maintenance_mode_enforced_when_ip_not_in_allowed_list(
self, mock_get_client_ip
):
response = self.client.get("/")
self.assertEquals(response.status_code, 503)
self.assertEqual(response.status_code, 503)


class TestInterpretCookiesMiddleware(SimpleTestCase):
Expand Down
2 changes: 1 addition & 1 deletion etna/records/tests/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,4 @@ def test_view_edit_page_with_client_api_exception(self):
reverse("wagtailadmin_pages:edit", args=(self.article_page.id,))
)

self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
4 changes: 2 additions & 2 deletions etna/records/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def test_thumbnail_url(self):
images = Image.search.filter(rid="")
image = images[0]

self.assertEquals(
self.assertEqual(
image.thumbnail_url, "https://media.preview/path/to/thumbnail.jpeg"
)

Expand All @@ -610,7 +610,7 @@ def test_thumbnail_url_fallback(self):
image = images[0]

# Fallback serves image through Wagtail instead of from Client API
self.assertEquals(image.thumbnail_url, "/records/image/path/to/image.jpeg")
self.assertEqual(image.thumbnail_url, "/records/image/path/to/image.jpeg")


@override_settings(CLIENT_BASE_URL=f"{settings.CLIENT_BASE_URL}")
Expand Down
2 changes: 1 addition & 1 deletion etna/records/tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_resolves_iaid(self):
def test_iaid_with_non_standard_prefix(self):
resolver = resolve("/catalogue/id/C123456/")

self.assertEquals(resolver.view_name, "details-page-machine-readable")
self.assertEqual(resolver.view_name, "details-page-machine-readable")
self.assertEqual(resolver.kwargs["iaid"], "C123456")

def test_resolves_uuid(self):
Expand Down
Loading