Skip to content

Commit

Permalink
Linter Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbokhan committed Oct 28, 2024
1 parent 4177d6d commit 696fc5a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
2 changes: 1 addition & 1 deletion prsw/ripe_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`."""
Expand Down
10 changes: 3 additions & 7 deletions prsw/stat/address_space_hierarchy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Provides the Address Space Hierarchy endpoint."""
from collections import namedtuple

import ipaddress
from datetime import datetime
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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"])
23 changes: 7 additions & 16 deletions tests/unit/stat/test_address_space_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -55,26 +55,22 @@ 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,
"server_id": "app127",
"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"

Expand Down Expand Up @@ -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)
Expand All @@ -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)


0 comments on commit 696fc5a

Please sign in to comment.