Skip to content

Commit

Permalink
Replace assertEquals usage
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Oct 23, 2024
1 parent e95567a commit 846449f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 67 deletions.
74 changes: 37 additions & 37 deletions ureport/bots/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def test_create_bot(self):

self.login(self.admin)
response = self.client.get(create_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(response.status_code, 200)
self.assertEquals(len(response.context["form"].fields), 12)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context["form"].fields), 12)
self.assertNotIn("org", response.context["form"].fields)

post_data = dict()
Expand All @@ -34,22 +34,22 @@ def test_create_bot(self):
)
response = self.client.post(create_url, post_data, follow=True, SERVER_NAME="uganda.ureport.io")
bot = Bot.objects.order_by("-pk")[0]
self.assertEquals(response.status_code, 200)
self.assertEquals(response.request["PATH_INFO"], reverse("bots.bot_list"))
self.assertEquals(bot.title, "WhatsApp")
self.assertEquals(bot.org, self.uganda)
self.assertEquals(bot.channel, "+12345")
self.assertEquals(bot.keyword, "join")
self.assertEquals(bot.facebook_deeplink, "https://example.com/12345")
self.assertEquals(bot.description, "The main channel")
self.assertEquals(bot.priority, 1)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.request["PATH_INFO"], reverse("bots.bot_list"))
self.assertEqual(bot.title, "WhatsApp")
self.assertEqual(bot.org, self.uganda)
self.assertEqual(bot.channel, "+12345")
self.assertEqual(bot.keyword, "join")
self.assertEqual(bot.facebook_deeplink, "https://example.com/12345")
self.assertEqual(bot.description, "The main channel")
self.assertEqual(bot.priority, 1)
self.assertTrue(bot.featured)
self.assertFalse(bot.landing_page_only)

self.login(self.superuser)
response = self.client.get(create_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(response.status_code, 200)
self.assertEquals(len(response.context["form"].fields), 12)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context["form"].fields), 12)
self.assertNotIn("org", response.context["form"].fields)

post_data = dict(
Expand All @@ -62,15 +62,15 @@ def test_create_bot(self):
)
response = self.client.post(create_url, post_data, follow=True, SERVER_NAME="uganda.ureport.io")
bot = Bot.objects.order_by("-pk")[0]
self.assertEquals(response.status_code, 200)
self.assertEquals(response.request["PATH_INFO"], reverse("bots.bot_list"))
self.assertEquals(bot.title, "Facebook")
self.assertEquals(bot.org, self.uganda)
self.assertEquals(bot.channel, "HereWeGo")
self.assertEquals(bot.keyword, "participate")
self.assertEquals(bot.facebook_deeplink, "https://example.com/herewego")
self.assertEquals(bot.description, "The Facebook channel")
self.assertEquals(bot.priority, 2)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.request["PATH_INFO"], reverse("bots.bot_list"))
self.assertEqual(bot.title, "Facebook")
self.assertEqual(bot.org, self.uganda)
self.assertEqual(bot.channel, "HereWeGo")
self.assertEqual(bot.keyword, "participate")
self.assertEqual(bot.facebook_deeplink, "https://example.com/herewego")
self.assertEqual(bot.description, "The Facebook channel")
self.assertEqual(bot.priority, 2)
self.assertFalse(bot.featured)
self.assertFalse(bot.landing_page_only)

Expand Down Expand Up @@ -124,22 +124,22 @@ def test_list(self):

self.login(self.admin)
response = self.client.get(list_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(len(response.context["object_list"]), 2)
self.assertEqual(len(response.context["object_list"]), 2)
self.assertNotIn(nigeria_wa_bot, response.context["object_list"])
self.assertIn(uganda_wa_bot, response.context["object_list"])
self.assertIn(uganda_fb_bot, response.context["object_list"])

response = self.client.get(list_url, SERVER_NAME="nigeria.ureport.io")
self.assertEquals(len(response.context["object_list"]), 1)
self.assertEqual(len(response.context["object_list"]), 1)
self.assertNotIn(uganda_wa_bot, response.context["object_list"])
self.assertNotIn(uganda_wa_bot, response.context["object_list"])
self.assertIn(nigeria_wa_bot, response.context["object_list"])
self.assertEquals(len(response.context["fields"]), 5)
self.assertEqual(len(response.context["fields"]), 5)

self.login(self.superuser)
response = self.client.get(list_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(len(response.context["fields"]), 5)
self.assertEquals(len(response.context["object_list"]), 2)
self.assertEqual(len(response.context["fields"]), 5)
self.assertEqual(len(response.context["object_list"]), 2)
self.assertIn(uganda_wa_bot, response.context["object_list"])
self.assertIn(uganda_wa_bot, response.context["object_list"])
self.assertNotIn(nigeria_wa_bot, response.context["object_list"])
Expand Down Expand Up @@ -188,8 +188,8 @@ def test_bot_update(self):
self.assertLoginRedirect(response)

response = self.client.get(uganda_update_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(response.status_code, 200)
self.assertEquals(len(response.context["form"].fields), 13)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context["form"].fields), 13)

post_data = dict(
is_active=True,
Expand All @@ -203,14 +203,14 @@ def test_bot_update(self):
priority=3,
)
response = self.client.post(uganda_update_url, post_data, follow=True, SERVER_NAME="uganda.ureport.io")
self.assertEquals(response.request["PATH_INFO"], reverse("bots.bot_list"))
self.assertEqual(response.request["PATH_INFO"], reverse("bots.bot_list"))
bot = Bot.objects.get(pk=uganda_fb_bot.pk)
self.assertEquals(bot.title, "WhatsApp")
self.assertEquals(bot.org, self.uganda)
self.assertEquals(bot.channel, "+12345")
self.assertEquals(bot.keyword, "join")
self.assertEquals(bot.facebook_deeplink, "https://example.com/12345")
self.assertEquals(bot.description, "The main channel")
self.assertEquals(bot.priority, 3)
self.assertEqual(bot.title, "WhatsApp")
self.assertEqual(bot.org, self.uganda)
self.assertEqual(bot.channel, "+12345")
self.assertEqual(bot.keyword, "join")
self.assertEqual(bot.facebook_deeplink, "https://example.com/12345")
self.assertEqual(bot.description, "The main channel")
self.assertEqual(bot.priority, 3)
self.assertTrue(bot.featured)
self.assertTrue(bot.landing_page_only)
42 changes: 21 additions & 21 deletions ureport/landingpages/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def test_create(self):

self.login(self.admin)
response = self.client.get(create_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(response.status_code, 200)
self.assertEquals(len(response.context["form"].fields), 7)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context["form"].fields), 7)
self.assertNotIn("org", response.context["form"].fields)

post_data = dict()
Expand All @@ -32,15 +32,15 @@ def test_create(self):
response = self.client.post(create_url, post_data, follow=True, SERVER_NAME="uganda.ureport.io")
landing_page = LandingPage.objects.order_by("-pk")[0]

self.assertEquals(response.status_code, 200)
self.assertEquals(response.request["PATH_INFO"], reverse("landingpages.landingpage_list"))
self.assertEquals(landing_page.title, "Welcome")
self.assertEquals(landing_page.slug, "lorem")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.request["PATH_INFO"], reverse("landingpages.landingpage_list"))
self.assertEqual(landing_page.title, "Welcome")
self.assertEqual(landing_page.slug, "lorem")

self.login(self.superuser)
response = self.client.get(create_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(response.status_code, 200)
self.assertEquals(len(response.context["form"].fields), 7)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context["form"].fields), 7)
self.assertNotIn("org", response.context["form"].fields)

post_data = dict(
Expand All @@ -51,8 +51,8 @@ def test_create(self):

response = self.client.post(create_url, post_data, follow=True, SERVER_NAME="uganda.ureport.io")
landing_page = LandingPage.objects.order_by("-pk")[0]
self.assertEquals(landing_page.title, "Foo Bar")
self.assertEquals(landing_page.slug, "foo")
self.assertEqual(landing_page.title, "Foo Bar")
self.assertEqual(landing_page.slug, "foo")

def test_list(self):
uganda_foo_lp = LandingPage.objects.create(
Expand Down Expand Up @@ -89,23 +89,23 @@ def test_list(self):

self.login(self.admin)
response = self.client.get(list_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(len(response.context["object_list"]), 2)
self.assertEqual(len(response.context["object_list"]), 2)

self.assertNotIn(nigeria_foo_lp, response.context["object_list"])
self.assertIn(uganda_foo_lp, response.context["object_list"])
self.assertIn(uganda_bar_lp, response.context["object_list"])

response = self.client.get(list_url, SERVER_NAME="nigeria.ureport.io")
self.assertEquals(len(response.context["object_list"]), 1)
self.assertEqual(len(response.context["object_list"]), 1)
self.assertNotIn(uganda_foo_lp, response.context["object_list"])
self.assertNotIn(uganda_bar_lp, response.context["object_list"])
self.assertIn(nigeria_foo_lp, response.context["object_list"])
self.assertEquals(len(response.context["fields"]), 3)
self.assertEqual(len(response.context["fields"]), 3)

self.login(self.superuser)
response = self.client.get(list_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(len(response.context["fields"]), 3)
self.assertEquals(len(response.context["object_list"]), 2)
self.assertEqual(len(response.context["fields"]), 3)
self.assertEqual(len(response.context["object_list"]), 2)
self.assertIn(uganda_foo_lp, response.context["object_list"])
self.assertIn(uganda_bar_lp, response.context["object_list"])
self.assertNotIn(nigeria_foo_lp, response.context["object_list"])
Expand Down Expand Up @@ -171,8 +171,8 @@ def test_bot_update(self):
self.assertLoginRedirect(response)

response = self.client.get(uganda_update_url, SERVER_NAME="uganda.ureport.io")
self.assertEquals(response.status_code, 200)
self.assertEquals(len(response.context["form"].fields), 8)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context["form"].fields), 8)
self.assertEqual(
list(response.context["form"].fields["bots"].choices),
[(uganda_fb_bot.pk, "Facebook Bot")],
Expand All @@ -185,8 +185,8 @@ def test_bot_update(self):
)

response = self.client.post(uganda_update_url, post_data, follow=True, SERVER_NAME="uganda.ureport.io")
self.assertEquals(response.request["PATH_INFO"], reverse("landingpages.landingpage_list"))
self.assertEqual(response.request["PATH_INFO"], reverse("landingpages.landingpage_list"))
landing_page = LandingPage.objects.get(pk=uganda_foo_lp.pk)
self.assertEquals(landing_page.title, "Bar Bar")
self.assertEquals(landing_page.slug, "bar")
self.assertEquals(landing_page.content, "Phasellus id arcu quis urna faucibus eleifend.")
self.assertEqual(landing_page.title, "Bar Bar")
self.assertEqual(landing_page.slug, "bar")
self.assertEqual(landing_page.content, "Phasellus id arcu quis urna faucibus eleifend.")
18 changes: 9 additions & 9 deletions ureport/polls/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def test_get_flow(self):

poll1 = self.create_poll(self.uganda, "Poll 1", "uuid-1", self.health_uganda, self.admin, featured=True)

self.assertEquals(poll1.get_flow(), "Flow")
self.assertEqual(poll1.get_flow(), "Flow")
mock.assert_called_once_with(backend=poll1.backend)

def test_runs(self):
Expand Down Expand Up @@ -465,9 +465,9 @@ def test_create_poll(self):
self.assertTrue(Poll.objects.all())

poll = Poll.objects.get()
self.assertEquals(poll.title, "Poll 1")
self.assertEquals(poll.backend.slug, "rapidpro")
self.assertEquals(poll.org, self.uganda)
self.assertEqual(poll.title, "Poll 1")
self.assertEqual(poll.backend.slug, "rapidpro")
self.assertEqual(poll.org, self.uganda)

self.assertEqual(poll.tags.all().count(), 2)
self.assertEqual(set(poll.tags.all().values_list("name", flat=True)), {"Books", "sports"})
Expand Down Expand Up @@ -562,8 +562,8 @@ def test_create_poll(self):
self.assertIn("loc", response.context["form"].fields)

self.assertIn("backend", response.context["form"].fields)
self.assertEquals(len(response.context["form"].fields["backend"].choices), 3)
self.assertEquals(
self.assertEqual(len(response.context["form"].fields["backend"].choices), 3)
self.assertEqual(
set(
[
(getattr(elt[0], "value", ""), elt[1])
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def test_templatetags(self):
mock.return_value = "Done"

self.assertIsNone(config(None, "field_name"))
self.assertEquals(config(self.uganda, "field_name"), "Done")
self.assertEqual(config(self.uganda, "field_name"), "Done")
mock.assert_called_with("field_name")

self.assertIsNone(org_color(None, 1))
Expand Down Expand Up @@ -1456,12 +1456,12 @@ def test_poll_question_model(self):
self.assertFalse(PollWordCloud.objects.all())
poll_question1.generate_word_cloud()
self.assertTrue(PollWordCloud.objects.all())
self.assertEquals(PollWordCloud.objects.all().count(), 1)
self.assertEqual(PollWordCloud.objects.all().count(), 1)

# another run will keep the same DB object
poll_question1.generate_word_cloud()
self.assertTrue(PollWordCloud.objects.all())
self.assertEquals(PollWordCloud.objects.all().count(), 1)
self.assertEqual(PollWordCloud.objects.all().count(), 1)

results = poll_question1.calculate_results()
result = results[0]
Expand Down

0 comments on commit 846449f

Please sign in to comment.