From b5f3b32673c8882476fd94a27491597bc16e2abe Mon Sep 17 00:00:00 2001 From: AnAccountForReportingBugs <45908752+AnAccountForReportingBugs@users.noreply.github.com> Date: Thu, 7 Mar 2019 17:54:27 -0600 Subject: [PATCH] rest-api: update tests to v1.1.1 Fixes #1673 --- exercises/rest-api/rest_api_test.py | 52 ++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/exercises/rest-api/rest_api_test.py b/exercises/rest-api/rest_api_test.py index d98a2a72886..f6c1886cb58 100644 --- a/exercises/rest-api/rest_api_test.py +++ b/exercises/rest-api/rest_api_test.py @@ -4,7 +4,7 @@ from rest_api import RestAPI -# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.2 +# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.1 class RestAPITest(unittest.TestCase): def test_no_users(self): @@ -325,6 +325,56 @@ def test_lender_owes_borrower_less_than_new_loan(self): } self.assertDictEqual(json.loads(response), expected) + def test_lender_owes_borrower_same_as_new_loan(self): + database = { + "users": [ + { + "name": "Adam", + "owes": { + "Bob": 3.0 + }, + "owed_by": {}, + "balance": -3.0 + }, + { + "name": "Bob", + "owes": {}, + "owed_by": { + "Adam": 3.0 + }, + "balance": 3.0 + } + ] + } + api = RestAPI(database) + payload = json.dumps({ + 'lender': 'Adam', + 'borrower': 'Bob', + 'amount': 3.0 + }) + response = api.post('/iou', payload) + expected = { + 'users': [ + { + "name": "Adam", + "owes": { + }, + "owed_by": { + }, + "balance": 0.0 + }, + { + "name": "Bob", + "owes": { + }, + "owed_by": { + }, + "balance": 0.0 + } + ] + } + self.assertDictEqual(json.loads(response), expected) + if __name__ == '__main__': unittest.main()