Skip to content

Commit

Permalink
2.9.0 - Re-tagged with fixed tests
Browse files Browse the repository at this point in the history
Github version has been re-tagged. No changes to actual package code, as tests are generally excluded.

 - `tests.test_net.TestNet._check_asn` now allows comparing against multiple AS names,
   reducing risk of ASN test breakage due to AS names changing.

 - Added additional AS names to `test_asn_to_name_int` and `test_asn_to_name_str` to repair
   test breakage caused by Cloudflare's AS name changing, and preventing breakage caused by
   AS name changes in future.
  • Loading branch information
Someguy123 committed Mar 17, 2020
1 parent 48ce4b6 commit 47345a2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,22 @@ def test_ping_v6(self):
except helpers.NetworkUnreachable as e:
return pytest.skip(f"Skipping test TestGeneral.test_ping_v6 as network is unavailable: \"{str(e)}\"")

def _check_asn(self, asn, expected_name):
def _check_asn(self, asn, *expected_names):
if not HAS_DNSPYTHON:
return pytest.skip(f"Skipping asn_to_name tests as dnspython is not installed...")
name = helpers.asn_to_name(asn)
self.assertEqual(name, expected_name, msg=f"asn_to_name({asn}) '{name}' == '{expected_name}'")
expected_names = list(expected_names)
self.assertIn(name, expected_names, msg=f"asn_to_name({asn}) '{name}' in: {expected_names}")

@pytest.mark.skipif(not HAS_DNSPYTHON, reason="test_asn_to_name_int requires package 'dnspython'")
def test_asn_to_name_int(self):
"""Test Privex's ASN (as an int) 210083 resolves to 'PRIVEX, SE'"""
self._check_asn(210083, 'PRIVEX, SE')
self._check_asn(210083, 'PRIVEX, SE', 'PRIVEX INC, SE', 'Privex Inc, SE')

@pytest.mark.skipif(not HAS_DNSPYTHON, reason="test_asn_to_name_str requires package 'dnspython'")
def test_asn_to_name_str(self):
"""Test Cloudflare's ASN (as a str) '13335' resolves to 'CLOUDFLARENET - Cloudflare, Inc., US'"""
self._check_asn('13335', 'CLOUDFLARENET - Cloudflare, Inc., US')
self._check_asn('13335', 'CLOUDFLARENET - Cloudflare, Inc., US', 'CLOUDFLARENET, US')

@pytest.mark.skipif(not HAS_DNSPYTHON, reason="test_asn_to_name_erroneous requires package 'dnspython'")
def test_asn_to_name_erroneous(self):
Expand Down

0 comments on commit 47345a2

Please sign in to comment.