Fix Sonar issue, formatting (#99)
* Fix Sonar issue, formatting * Remove dev dependencies from requirements.tzt * Fix unit test failure
This commit is contained in:
@ -5,15 +5,15 @@
|
||||
import requests_mock
|
||||
|
||||
from app.ip_info import ( # pragma: no cover
|
||||
get_ip_information,
|
||||
get_autonomous_system_number,
|
||||
get_ip_information,
|
||||
get_prefix_information,
|
||||
)
|
||||
|
||||
|
||||
def test_get_ip_information() -> None:
|
||||
"""TEST: ensure that the IP information API is working correctly."""
|
||||
test_query = "1.2.3.4"
|
||||
test_query: str = "1.2.3.4"
|
||||
ip_info = get_ip_information(test_query)
|
||||
assert ip_info.get("status") == "success" and ip_info.get("query") == test_query
|
||||
|
||||
@ -39,7 +39,7 @@ def test_get_ip_information_bad_response() -> None:
|
||||
def test_get_autonomous_system_number() -> None:
|
||||
"""TEST: ensure that AS information is parsed into AS number correctly."""
|
||||
as_info = "AS5089 Virgin Media Limited"
|
||||
as_number = get_autonomous_system_number(as_info)
|
||||
as_number: str = get_autonomous_system_number(as_info)
|
||||
assert as_number == "AS5089"
|
||||
|
||||
|
||||
|
@ -7,13 +7,13 @@ from app.print_table import generate_prefix_string # pragma: no cover
|
||||
|
||||
def test_generate_prefix_string_small() -> None:
|
||||
"""TEST: Verifies if a small prefix list results in one line."""
|
||||
test_query = ["abc", "def"]
|
||||
result = generate_prefix_string(prefixes=test_query)
|
||||
test_query: list[str] = ["abc", "def"]
|
||||
result: str | None = generate_prefix_string(prefixes=test_query)
|
||||
assert result == "abc, def\n"
|
||||
|
||||
|
||||
def test_generate_prefix_string_large() -> None:
|
||||
"""TEST: Verifies if a large prefix list results in multiple lines."""
|
||||
test_query = ["abc", "def", "ghi", "jkl", "mno", "pqr"]
|
||||
result = generate_prefix_string(prefixes=test_query)
|
||||
test_query: list[str] = ["abc", "def", "ghi", "jkl", "mno", "pqr"]
|
||||
result: str | None = generate_prefix_string(prefixes=test_query)
|
||||
assert result == "abc, def, ghi, jkl\nmno, pqr\n"
|
||||
|
@ -3,9 +3,9 @@
|
||||
"""MODULE: Provides test cases for app/query_normalisation.py."""
|
||||
|
||||
from app.query_normalisation import ( # pragma: no cover
|
||||
get_public_ip,
|
||||
is_ip_address,
|
||||
resolve_domain_name,
|
||||
get_public_ip,
|
||||
)
|
||||
|
||||
|
||||
@ -30,8 +30,8 @@ def test_is_ip_address_false_fqdn() -> None:
|
||||
def test_resolve_domain_name_true() -> None:
|
||||
"""TEST: Verifies that DNS resolution is working correctly."""
|
||||
domain_name = "one.one.one.one"
|
||||
expected_results = ["1.1.1.1", "1.0.0.1"] # Could resolve to either IP
|
||||
assert resolve_domain_name(domain_name) in expected_results
|
||||
expected_results: list[str] = ["1.1.1.1", "1.0.0.1"] # Could resolve to either IP
|
||||
assert str(resolve_domain_name(domain_name)) in expected_results
|
||||
|
||||
|
||||
def test_resolve_domain_name_false() -> None:
|
||||
|
Reference in New Issue
Block a user