Skip to content

Commit

Permalink
generalize the checkout tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kPsarakis committed May 4, 2022
1 parent 4618559 commit 132e9d8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/test_microservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def test_order(self):
subtract_stock_response = tu.subtract_stock(item_id2, 1)
self.assertTrue(tu.status_code_is_success(subtract_stock_response))

checkout_response = tu.checkout_order(order_id).text
self.assertEqual(checkout_response, "Out of stock on item_id: " + str(item_id2))
checkout_response = tu.checkout_order(order_id).status_code
self.assertTrue(tu.status_code_is_failure(checkout_response))

stock_after_subtract: int = tu.find_item(item_id1)['stock']
self.assertEqual(stock_after_subtract, 15)
Expand All @@ -120,8 +120,8 @@ def test_order(self):
credit_after_payment: int = tu.find_user(user_id)['credit']
self.assertEqual(credit_after_payment, 0)

checkout_response = tu.checkout_order(order_id).text
self.assertEqual(checkout_response, "User out of credit")
checkout_response = tu.checkout_order(order_id).status_code
self.assertTrue(tu.status_code_is_failure(checkout_response))

add_credit_response = tu.add_credit_to_user(user_id, 15)
self.assertTrue(tu.status_code_is_success(int(add_credit_response)))
Expand All @@ -132,8 +132,8 @@ def test_order(self):
stock: int = tu.find_item(item_id1)['stock']
self.assertEqual(stock, 15)

checkout_response = tu.checkout_order(order_id).json()
self.assertEqual(checkout_response, "Checkout successful")
checkout_response = tu.checkout_order(order_id).status_code
self.assertTrue(tu.status_code_is_success(checkout_response))

stock_after_subtract: int = tu.find_item(item_id1)['stock']
self.assertEqual(stock_after_subtract, 14)
Expand Down

0 comments on commit 132e9d8

Please sign in to comment.