Skip to content

Commit

Permalink
check if link anaylysis date adn link last functioning date are the same
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNilges committed Jan 30, 2025
1 parent b1b7bc4 commit 3b3e24d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/meshapi/tests/test_uisp_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def test_notify_admins_autodetect_ap(self, mock_notify):
" - Mock change 2",
)


class TestUISPImportUpdateObjects(TransactionTestCase):
def setUp(self):
self.node1 = Node(
Expand Down Expand Up @@ -439,9 +440,9 @@ def test_update_link_many_changes(self, mock_get_last_seen):
self.assertEqual(
change_messages,
[
'Changed UISP link ID to fake-uisp-uuid2 for NN1234 ↔ NN5678 link (ID '
f'{self.link.id}). This is likely due to a UISP UUID '
'rotation',
"Changed UISP link ID to fake-uisp-uuid2 for NN1234 ↔ NN5678 link (ID "
f"{self.link.id}). This is likely due to a UISP UUID "
"rotation",
"Changed connected device pair from [nycmesh-1234-dev1, nycmesh-5678-dev2] to [nycmesh-1234-dev1, nycmesh-9012-dev3]",
"Marked as Inactive due to it being offline in UISP for more than 30 days",
],
Expand All @@ -463,7 +464,6 @@ def test_update_link_many_changes(self, mock_get_last_seen):
self.link.refresh_from_db()
self.assertEqual(2, len(self.link.history.all()))


@patch("meshapi.util.uisp_import.update_objects.get_uisp_link_last_seen")
def test_update_link_add_abandon_date(self, mock_get_last_seen):
self.link.status = Link.LinkStatus.INACTIVE
Expand Down
7 changes: 6 additions & 1 deletion src/meshapi/util/uisp_import/sync_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,16 @@ def sync_link_table_into_los_objects() -> None:
changed_los = True

# Keep the LOS analysis date accurate for all that come from existing links
if existing_los.source == LOS.LOSSource.EXISTING_LINK and link.last_functioning_date_estimate:
if (
existing_los.source == LOS.LOSSource.EXISTING_LINK
and link.last_functioning_date_estimate
and existing_los.analysis_date != link.last_functioning_date_estimate
):
existing_los.analysis_date = link.last_functioning_date_estimate
changed_los = True

if changed_los:
print("changed los")
existing_los.save()
continue

Expand Down

0 comments on commit 3b3e24d

Please sign in to comment.