@@ -1035,29 +1035,36 @@ def test_deactivated_device(self):
10351035 self .assertEqual (response .status_code , 403 )
10361036
10371037 def test_floorplan_coordinates (self ):
1038- org = self ._create_org ()
1038+ org = self ._get_org ()
10391039 location = self ._create_location (type = "indoor" , organization = org )
1040- floor1 = self ._create_floorplan (floor = 1 , location = location )
1041- floor2 = self ._create_floorplan (floor = 2 , location = location )
1042- device1 = self ._create_device (
1040+ f1 = self ._create_floorplan (floor = 1 , location = location )
1041+ f2 = self ._create_floorplan (floor = 2 , location = location )
1042+ d1 = self ._create_device (
10431043 name = "device1" , mac_address = "00:00:00:00:00:01" , organization = org
10441044 )
1045- device2 = self ._create_device (
1045+ d2 = self ._create_device (
10461046 name = "device2" , mac_address = "00:00:00:00:00:02" , organization = org
10471047 )
10481048 self ._create_object_location (
1049- content_object = device1 ,
1049+ content_object = d1 ,
10501050 location = location ,
1051- floorplan = floor1 ,
1051+ floorplan = f1 ,
10521052 organization = org ,
10531053 )
10541054 self ._create_object_location (
1055- content_object = device2 ,
1055+ content_object = d2 ,
10561056 location = location ,
1057- floorplan = floor2 ,
1057+ floorplan = f2 ,
10581058 organization = org ,
10591059 )
10601060 path = reverse ("geo_api:floorplan_coordinates_list" , args = [location .id ])
10611061 response = self .client .get (path )
1062- response = response .json ()
1063- print (response )
1062+ self .assertEqual (response .status_code , 200 )
1063+ self .assertEqual (len (response .data ), 2 )
1064+ self .assertEqual (response .data [0 ]["name" ], "device1" )
1065+
1066+ with self .subTest ("Test filter by floor" ):
1067+ response = self .client .get (f"{ path } ?floor=2" )
1068+ self .assertEqual (response .status_code , 200 )
1069+ self .assertEqual (len (response .data ), 1 )
1070+ self .assertEqual (response .data [0 ]["name" ], "device2" )
0 commit comments