1818Device = load_model ('config' , 'Device' )
1919DeviceConnection = load_model ('connection' , 'DeviceConnection' )
2020Location = load_model ('geo' , 'Location' )
21+ FloorPlan = load_model ('geo' , 'FloorPlan' )
2122DeviceLocation = load_model ('geo' , 'DeviceLocation' )
2223
2324
2425@tag ('selenium_tests' )
25- class TestDeviceConnectionInlineAdmin (
26+ class TestDevice (
2627 CreateConnectionsMixin , TestGeoMixin , SeleniumTestMixin , StaticLiveServerTestCase
2728):
2829 config_app_label = 'config'
2930 location_model = Location
3031 object_location_model = DeviceLocation
32+ floorplan_model = FloorPlan
3133
3234 def setUp (self ):
3335 self .admin = self ._create_admin (
@@ -40,10 +42,14 @@ def test_restoring_deleted_device(self, *args):
4042 self ._create_credentials (auto_add = True , organization = org )
4143 config = self ._create_config (organization = org )
4244 device = config .device
45+
46+ location = self ._create_location (organization = org , type = 'indoor' )
47+ floorplan = self ._create_floorplan (
48+ location = location ,
49+ )
4350 self ._create_object_location (
44- location = self ._create_location (
45- organization = org ,
46- ),
51+ location = location ,
52+ floorplan = floorplan ,
4753 content_object = device ,
4854 )
4955 self .assertEqual (device .deviceconnection_set .count (), 1 )
@@ -59,9 +65,13 @@ def test_restoring_deleted_device(self, *args):
5965 self .web_driver .find_element (
6066 by = By .XPATH , value = '//*[@id="content"]/form/div/input[2]'
6167 ).click ()
68+ # Delete location object
69+ location .delete ()
6270 self .assertEqual (Device .objects .count (), 0 )
6371 self .assertEqual (DeviceConnection .objects .count (), 0 )
6472 self .assertEqual (DeviceLocation .objects .count (), 0 )
73+ self .assertEqual (self .location_model .objects .count (), 0 )
74+ self .assertEqual (self .floorplan_model .objects .count (), 0 )
6575
6676 version_obj = Version .objects .get_deleted (model = Device ).first ()
6777
@@ -94,3 +104,8 @@ def test_restoring_deleted_device(self, *args):
94104 self .assertEqual (Device .objects .count (), 1 )
95105 self .assertEqual (DeviceConnection .objects .count (), 1 )
96106 self .assertEqual (DeviceLocation .objects .count (), 1 )
107+ self .assertEqual (self .location_model .objects .count (), 1 )
108+ # The FloorPlan object is not recoverable because deleting it
109+ # also removes the associated image from the filesystem,
110+ # which cannot be restored.
111+ self .assertEqual (self .floorplan_model .objects .count (), 0 )
0 commit comments