Skip to content

Commit

Permalink
Fix patch mark test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBloodMan49 committed Nov 27, 2024
1 parent a845605 commit f173b54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions backend/langate/network/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,9 @@ def test_get_marks(self, mock_settings):
self.assertEqual(response.data[i]["devices"], Device.objects.filter(mark=self.settings["marks"][i]["value"], whitelisted=False).count())
self.assertEqual(response.data[i]["whitelisted"], Device.objects.filter(mark=self.settings["marks"][i]["value"], whitelisted=True).count())

@patch('langate.settings.netcontrol.set_mark', return_value=None)
@patch('langate.network.views.save_settings')
def test_patch_marks(self, mock_save_settings):
def test_patch_marks(self, mock_save_settings, mock_set_mark):
mock_save_settings.side_effect = lambda x: None

new_marks = [
Expand All @@ -603,7 +604,7 @@ def test_patch_marks(self, mock_save_settings):

from langate.settings import SETTINGS as ORIGINAL_SETTINGS

self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(ORIGINAL_SETTINGS["marks"]), 2)
self.assertEqual(ORIGINAL_SETTINGS["marks"][0]["value"], 102)
self.assertEqual(ORIGINAL_SETTINGS["marks"][1]["value"], 103)
Expand Down
3 changes: 1 addition & 2 deletions backend/langate/network/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def patch(self, request):
removed_marks = [m for m in old_marks if m not in new_marks]

SETTINGS["marks"] = marks
save_settings(SETTINGS)

if removed_marks:
for mark in removed_marks:
Expand All @@ -337,8 +338,6 @@ def patch(self, request):
new = get_mark(excluded_marks=[mark])
DeviceManager.edit_device(device, device.mac, device.name, new)

save_settings(SETTINGS)

return Response(SETTINGS["marks"], status=status.HTTP_200_OK)

class MarkMove(APIView):
Expand Down

0 comments on commit f173b54

Please sign in to comment.