def __init__(self, nw, baking_address, verbose=False, base_url=None): super(TzKTRewardApiImpl, self).__init__() if base_url is None: self.api = TzKTApi.from_network(nw['NAME'].lower(), verbose=verbose) else: self.api = TzKTApi.from_url(base_url, verbose=verbose) self.baking_address = baking_address self.name = 'tzkt'
def __init__(self, nw, baking_address, base_url=None): super(TzKTRewardApiImpl, self).__init__() if base_url is None: self.api = TzKTApi.from_network(nw["NAME"]) else: self.api = TzKTApi.from_url(base_url) self.baking_address = baking_address self.name = "tzkt"
def test_request_content_response(): """Test the handling of API calls which respond with a content (200).""" baker_address = "tz1NortRftucvAkD1J58L32EhSVrQEWJCEnB" base_url = TZKT_PUBLIC_API_URL["MAINNET"] timeout = 30 cycle = 201 tzkt = TzKTApi(base_url, timeout) request_path = f"rewards/split/{baker_address}/{cycle}" response = tzkt._request(request_path, offset=0, limit=10000) assert isinstance(response, dict) assert response["cycle"] == cycle
def test_request_dns_lookup_error(): """Test the handling of API calls which respond with a DNS lookup error.""" # The baker address exists **only** on the mainnet baker_address = "tz1NortRftucvAkD1J58L32EhSVrQEWJCEnB" base_url = "https://not_existent_domain_name.com" timeout = 30 cycle = 201 tzkt = TzKTApi(base_url, timeout) request_path = f"rewards/split/{baker_address}/{cycle}" with pytest.raises(TzKTApiError, match="DNS lookup failed"): _ = tzkt._request(request_path, offset=0, limit=10000)
def test_request_no_content_response(): """Test the handling of API calls which respond with no content (204). Issue: https://github.com/tezos-reward-distributor-organization/tezos-reward-distributor/issues/404 """ # The baker address exists **only** on the mainnet baker_address = "tz1NortRftucvAkD1J58L32EhSVrQEWJCEnB" base_url = "" timeout = 30 cycle = 201 tzkt = TzKTApi(base_url, timeout) request_path = f"rewards/split/{baker_address}/{cycle}" res = tzkt._request(request_path, offset=0, limit=10000) assert res is None
def __init__(self, nw, base_url=None): super(TzKTBlockApiImpl, self).__init__(nw) if base_url is None: self.api = TzKTApi.from_network(nw['NAME']) else: self.api = TzKTApi.from_url(base_url)
def __init__(self, nw, verbose=False, base_url=None): super(TzKTBlockApiImpl, self).__init__(nw) if base_url is None: self.api = TzKTApi.from_network(nw['NAME'].lower(), verbose=verbose) else: self.api = TzKTApi.from_url(base_url, verbose=verbose)