From 132e9d87754015b7cf2c3ec67dfd6898a28ffa3b Mon Sep 17 00:00:00 2001 From: kPsarakis Date: Wed, 4 May 2022 11:01:59 +0200 Subject: [PATCH] generalize the checkout tests --- test/test_microservices.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_microservices.py b/test/test_microservices.py index a1f1537..3207af1 100644 --- a/test/test_microservices.py +++ b/test/test_microservices.py @@ -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) @@ -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))) @@ -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)