Skip to content

Commit 1ea5ef9

Browse files
authored
Merge pull request exercism#1716 from AnAccountForReportingBugs/patch-5
rest-api: update tests to v1.1.1
2 parents 8235356 + b5f3b32 commit 1ea5ef9

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

exercises/rest-api/rest_api_test.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from rest_api import RestAPI
55

66

7-
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.2
7+
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.1
88

99
class RestAPITest(unittest.TestCase):
1010
def test_no_users(self):
@@ -325,6 +325,56 @@ def test_lender_owes_borrower_less_than_new_loan(self):
325325
}
326326
self.assertDictEqual(json.loads(response), expected)
327327

328+
def test_lender_owes_borrower_same_as_new_loan(self):
329+
database = {
330+
"users": [
331+
{
332+
"name": "Adam",
333+
"owes": {
334+
"Bob": 3.0
335+
},
336+
"owed_by": {},
337+
"balance": -3.0
338+
},
339+
{
340+
"name": "Bob",
341+
"owes": {},
342+
"owed_by": {
343+
"Adam": 3.0
344+
},
345+
"balance": 3.0
346+
}
347+
]
348+
}
349+
api = RestAPI(database)
350+
payload = json.dumps({
351+
'lender': 'Adam',
352+
'borrower': 'Bob',
353+
'amount': 3.0
354+
})
355+
response = api.post('/iou', payload)
356+
expected = {
357+
'users': [
358+
{
359+
"name": "Adam",
360+
"owes": {
361+
},
362+
"owed_by": {
363+
},
364+
"balance": 0.0
365+
},
366+
{
367+
"name": "Bob",
368+
"owes": {
369+
},
370+
"owed_by": {
371+
},
372+
"balance": 0.0
373+
}
374+
]
375+
}
376+
self.assertDictEqual(json.loads(response), expected)
377+
328378

329379
if __name__ == '__main__':
330380
unittest.main()

0 commit comments

Comments
 (0)