def test_multiple_requests(self): api = FakeApi() api.get_inventory(test='awesome') api.fort_details() good_return_value = {'responses': {'GET_INVENTORY': {}, 'FORT_DETAILS': {}}, 'status_code': 0} api.setApiReturnValue(good_return_value) result = api.call() self.assertEqual(result, good_return_value)
def test_return_value_is_valid(self): api = FakeApi() # we set the return value below api.get_inventory(test='awesome') request = api.request_callers[0] # only one request self.assertEqual(request.upper(), 'GET_INVENTORY') good_return_value = {'responses': {request.upper(): {}}, 'status_code': 0} api.setApiReturnValue(good_return_value) result = api.call() self.assertEqual(result, good_return_value) self.assertEqual(len(api.request_callers), 0, 'request_callers must be empty')