Skip to content

Commit

Permalink
changes from main repo for list api fix (#4)
Browse files Browse the repository at this point in the history
* added workflows and tests

* added workflows and tests2

* fix workflows

* fix workflows 2

* fix workflows 3

* fix workflows 4

* fixed tests and fixed migrations

* fixing workflows 5

* fixing workflows 6

* fixing workflows 7

* fixing workflows 8

* fixing workflows 9

* fixing workflows 10

* fixing workflows 11

* fixing workflows 12

* fixing workflows 13

* fixing workflows 14

* fixing workflows 15

* fixing workflows 16

* fixing workflows 17

* fixing workflows 18

* fixing workflows 19

* fixing workflows 20

* fixing workflows 21

* fixed changes from main repo for list api fix
  • Loading branch information
DraKen0009 authored Dec 16, 2024
1 parent e098561 commit 01c66c3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
8 changes: 6 additions & 2 deletions camera/api/viewsets/position_preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,14 @@ def get_queryset(self):
)
if asset_external_id:
return queryset.filter(
asset_bed__asset=self.get_asset_obj(asset_external_id)
asset_bed__asset=self.get_asset_obj(asset_external_id),
asset_bed__deleted=False
)
if bed_external_id:
return queryset.filter(asset_bed__bed=self.get_bed_obj(bed_external_id))
return queryset.filter(
asset_bed__bed=self.get_bed_obj(bed_external_id),
asset_bed__deleted=False
)

if self.kwargs.get("external_id"):
return queryset.filter(external_id=self.kwargs.get("external_id"))
Expand Down
37 changes: 36 additions & 1 deletion camera/tests/test_camera_preset_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,42 @@ def test_create_camera_preset_with_same_name_in_same_bed(self):
)
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)


def test_list_bed_with_deleted_assetbed(self):
res = self.client.post(
self.get_base_url(self.asset_bed1.external_id),
{
"name": "Preset with proper position",
"position": {
"x": 1.0,
"y": 1.0,
"zoom": 1.0,
},
},
format="json",
)
self.assertEqual(res.status_code, status.HTTP_201_CREATED)
res = self.client.post(
self.get_base_url(self.asset_bed2.external_id),
{
"name": "Preset with proper position 2",
"position": {
"x": 1.0,
"y": 1.0,
"zoom": 1.0,
},
},
format="json",
)
self.assertEqual(res.status_code, status.HTTP_201_CREATED)

res = self.client.get(f"/api/camera/position-presets/?bed_external_id={self.bed.external_id}")
self.assertEqual(len(res.json()["results"]), 2)

self.asset_bed1.delete()
self.asset_bed1.refresh_from_db()
res = self.client.get(f"/api/camera/position-presets/?bed_external_id={self.bed.external_id}")
self.assertEqual(len(res.json()["results"]), 1)

def test_meta_validations_for_onvif_asset(self):
valid_meta = {
"local_ip_address": "192.168.0.1",
Expand Down

0 comments on commit 01c66c3

Please sign in to comment.