Skip to content

Commit

Permalink
tests: unit test assertion fixes (spiral-project#1203)
Browse files Browse the repository at this point in the history
`self.assertTrue(200, resp.status_code)` style are always True
and thus are useless. It looks like the original author wanted
`self.assertEqual` there instead.
  • Loading branch information
azmeuk authored Jul 28, 2023
1 parent afd8429 commit 2d0a487
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ihatemoney/tests/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def test_project(self):
},
)

self.assertTrue(400, resp.status_code)
self.assertEqual(400, resp.status_code)
self.assertEqual(
'{"contact_email": ["Invalid email address."]}\n', resp.data.decode("utf-8")
)

# create it
with self.app.mail.record_messages() as outbox:
resp = self.api_create("raclette")
self.assertTrue(201, resp.status_code)
self.assertEqual(201, resp.status_code)

# Check that email messages have been sent.
self.assertEqual(len(outbox), 1)
Expand All @@ -111,15 +111,15 @@ def test_project(self):
# create it twice should return a 400
resp = self.api_create("raclette")

self.assertTrue(400, resp.status_code)
self.assertEqual(400, resp.status_code)
self.assertIn("id", json.loads(resp.data.decode("utf-8")))

# get information about it
resp = self.client.get(
"/api/projects/raclette", headers=self.get_auth("raclette")
)

self.assertTrue(200, resp.status_code)
self.assertEqual(200, resp.status_code)
expected = {
"members": [],
"name": "raclette",
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_token_creation(self):

# Create project
resp = self.api_create("raclette")
self.assertTrue(201, resp.status_code)
self.assertEqual(201, resp.status_code)

# Get token
resp = self.client.get(
Expand Down Expand Up @@ -577,19 +577,19 @@ def test_bills_with_calculation(self):
def test_currencies(self):
# check /currencies for list of supported currencies
resp = self.client.get("/api/currencies")
self.assertTrue(201, resp.status_code)
self.assertEqual(200, resp.status_code)
self.assertIn("XXX", json.loads(resp.data.decode("utf-8")))

# create project with a default currency
resp = self.api_create("raclette", default_currency="EUR")
self.assertTrue(201, resp.status_code)
self.assertEqual(201, resp.status_code)

# get information about it
resp = self.client.get(
"/api/projects/raclette", headers=self.get_auth("raclette")
)

self.assertTrue(200, resp.status_code)
self.assertEqual(200, resp.status_code)
expected = {
"members": [],
"name": "raclette",
Expand Down

0 comments on commit 2d0a487

Please sign in to comment.