diff --git a/prsw/ripe_stat.py b/prsw/ripe_stat.py index 673c9b4..92efaca 100644 --- a/prsw/ripe_stat.py +++ b/prsw/ripe_stat.py @@ -88,7 +88,7 @@ def _get(self, path, params=None): def abuse_contact_finder(self) -> Type[AbuseContactFinder]: """Lazy alias to :class:`.stat.AbuseContactFinder`.""" return partial(AbuseContactFinder, self) - + @property def address_space_hierarchy(self) -> Type[AddressSpaceHierarchy]: """Lazy alias to :class:`.stat.AddressSpaceHierarchy`.""" diff --git a/prsw/stat/address_space_hierarchy.py b/prsw/stat/address_space_hierarchy.py index f7a888e..28fd941 100644 --- a/prsw/stat/address_space_hierarchy.py +++ b/prsw/stat/address_space_hierarchy.py @@ -1,5 +1,4 @@ """Provides the Address Space Hierarchy endpoint.""" -from collections import namedtuple import ipaddress from datetime import datetime @@ -55,7 +54,7 @@ def __init__(self, RIPEstat, resource): params = { "preferred_version": AddressSpaceHierarchy.VERSION, - "resource": str(resource) + "resource": str(resource), } self._api = RIPEstat._get(AddressSpaceHierarchy.PATH, params) @@ -103,7 +102,7 @@ def more_specific_inetnums(self): @property def less_specific_inetnums(self): """ - Returns a list containing first level less specific (parent) blocks + Returns a list containing first level less specific (parent) blocks above the queried resource. .. code-block:: python @@ -124,7 +123,4 @@ def rir(self): @property def query_time(self): """**datetime** of used by query.""" - return datetime.fromisoformat( - self._api.data["query_time"] - ) - + return datetime.fromisoformat(self._api.data["query_time"]) diff --git a/tests/unit/stat/test_address_space_hierarchy.py b/tests/unit/stat/test_address_space_hierarchy.py index 8f3560d..3e045f2 100644 --- a/tests/unit/stat/test_address_space_hierarchy.py +++ b/tests/unit/stat/test_address_space_hierarchy.py @@ -38,7 +38,7 @@ class TestAddressSpaceHierarchy(UnitTest): "mnt-by": "RIPE-NCC-MNT", "created": "2003-03-17T12:15:57Z", "last-modified": "2017-12-04T14:42:31Z", - "source": "RIPE" + "source": "RIPE", } ], "less_specific": [ @@ -55,15 +55,12 @@ class TestAddressSpaceHierarchy(UnitTest): "mnt-routes": "RIPE-NCC-MNT, RIPE-GII-MNT { 193.0.8.0/23 }", "created": "2012-03-09T15:03:38Z", "last-modified": "2024-07-24T15:35:02Z", - "source": "RIPE" + "source": "RIPE", } ], "more_specific": [], "query_time": "2024-10-10T14:42:39", - "parameters": { - "resource": "193.0.0.0/21", - "cache": None - } + "parameters": {"resource": "193.0.0.0/21", "cache": None}, }, "query_id": "20241010144239-e4fea150-ac7e-4ad4-94e3-1207a9c00f73", "process_time": 60, @@ -71,10 +68,9 @@ class TestAddressSpaceHierarchy(UnitTest): "build_version": "live.2024.9.25.217", "status": "ok", "status_code": 200, - "time": "2024-10-10T14:42:39.989690" + "time": "2024-10-10T14:42:39.989690", } - def setup_method(self): url = f"{API_URL}{AddressSpaceHierarchy.PATH}data.json?resource=193.0.0.0/21" @@ -115,24 +111,21 @@ def test_resource(self, mock_get): def test_exact_inetnums(self, mock_get): response = AddressSpaceHierarchy( - mock_get.ripestat, - resource=self.params["resource"] + mock_get.ripestat, resource=self.params["resource"] ) assert isinstance(response.exact_inetnums, Iterable) def test_more_specific_inetnums(self, mock_get): response = AddressSpaceHierarchy( - mock_get.ripestat, - resource=self.params["resource"] + mock_get.ripestat, resource=self.params["resource"] ) assert isinstance(response.more_specific_inetnums, Iterable) def test_less_specific_inetnums(self, mock_get): response = AddressSpaceHierarchy( - mock_get.ripestat, - resource=self.params["resource"] + mock_get.ripestat, resource=self.params["resource"] ) assert isinstance(response.less_specific_inetnums, Iterable) @@ -143,5 +136,3 @@ def test_query_time(self, mock_get): query_time = self.RESPONSE["data"]["query_time"] assert response.query_time == datetime.fromisoformat(query_time) - -