Skip to content

Commit

Permalink
Test invalid lines in oui file
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Aug 22, 2024
1 parent 768ef19 commit 73c37b2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/integration/update_ouis_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def test_old_ouis_should_be_deleted_if_they_dont_exist_in_new_oui_file(
assert not OUI.objects.filter(oui=old_vendor_oui).exists()


def test_invalid_oui_should_not_be_registered(db, mock_invalid_oui_file):
update_ouis()
assert OUI.objects.count() == 0


@pytest.fixture()
def mock_oui_file(monkeypatch):
mocked_oui_data = """
Expand Down Expand Up @@ -109,3 +114,20 @@ def mock_duplicate_oui_file(monkeypatch):
"""
download_file_mock = Mock(return_value=mocked_oui_data)
monkeypatch.setattr("nav.bin.update_ouis._download_oui_file", download_file_mock)


@pytest.fixture()
def mock_invalid_oui_file(monkeypatch):
mocked_oui_data = """
OUI/MA-L Organization
company_id Organization
Address
invalidhex (hex) INGRAM MICRO SERVICES
10E992 (base 16) INGRAM MICRO SERVICES
100 CHEMIN DE BAILLOT
MONTAUBAN 82000
FR
"""
download_file_mock = Mock(return_value=mocked_oui_data)
monkeypatch.setattr("nav.bin.update_ouis._download_oui_file", download_file_mock)

0 comments on commit 73c37b2

Please sign in to comment.