def test_success_fetch_blocks_on_page_2(requests_mock): results = [{ "id": "2bcd53c5-19f9-4226-ab04-3dfb17c3a1fe", "created_date": "2020-07-11T18:44:16.518695Z", "modified_date": "2020-07-11T18:44:16.518719Z", "block_identifier": "65ae26192dfb9ec41f88c6d582b374a9b42ab58833e1612452d7a8f685dcd4d5", "block": "3ff4ebb0-2b3d-429b-ba90-08133fcdee4e", "confirmation_validator": "fcd2dce8-9e4f-4bf1-8dac-cdbaf64e5ce8", "primary_validator": "51461a75-dd8d-4133-81f4-543a3b054149", }] address = "10.2.3.4" url = f"http://{address}:80/blocks" payload = { "count": 3, "next": None, "previous": f"{url}?limit=2", "results": results, } requests_mock.get(url, json=payload) bank = Bank(address=address) response = bank.fetch_blocks() assert response == payload
def test_success_fetch_blocks(requests_mock): result = [{ "id": "2bcd53c5-19f9-4226-ab04-3dfb17c3a1fe", "created_date": "2020-07-11T18:44:16.518695Z", "modified_date": "2020-07-11T18:44:16.518719Z", "block_identifier": "65ae26192dfb9ec41f88c6d582b374a9b42ab58833e1612452d7a8f685dcd4d5", "block": "3ff4ebb0-2b3d-429b-ba90-08133fcdee4e", "confirmation_validator": "fcd2dce8-9e4f-4bf1-8dac-cdbaf64e5ce8", "primary_validator": "51461a75-dd8d-4133-81f4-543a3b054149", }] requests_mock.get("http://10.2.3.4:80/blocks", json=result) bank = Bank(address="10.2.3.4") response = bank.fetch_blocks() assert response == result