From 73c37b288b71a8031a028921e28585893967d69c Mon Sep 17 00:00:00 2001 From: Simon Oliver Tveit Date: Thu, 22 Aug 2024 14:32:10 +0200 Subject: [PATCH] Test invalid lines in oui file --- tests/integration/update_ouis_test.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration/update_ouis_test.py b/tests/integration/update_ouis_test.py index 5306442457..74f86a7da5 100644 --- a/tests/integration/update_ouis_test.py +++ b/tests/integration/update_ouis_test.py @@ -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 = """ @@ -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)