diff --git a/tests/test_todos.py b/tests/test_todos.py index 5b74128..5e493ab 100644 --- a/tests/test_todos.py +++ b/tests/test_todos.py @@ -67,3 +67,22 @@ def testing_getting_uncompleted_todos_when_todos_is_none(): uncompleted_todos = get_uncompleted_todos() assert mock_get_todos.called assert uncompleted_todos == [] + + +def test_integration_contract(): + actual = get_todos() + actual_keys = actual.json().pop().keys() + + with patch('apitesting.services.requests.get') as mock_get: + mock_get.return_value.ok = True + mock_get.return_value.json.return_value = [{ + 'userId': 1, + 'id': 1, + 'title': 'Make the bed', + 'completed': False + }] + + mocked = get_todos() + mocked_keys = mocked.json().pop().keys() + + assert set(actual_keys) == set(mocked_keys)