1717from .utils import CreateCommandMixin , CreateConnectionsMixin
1818
1919Command = load_model ('connection' , 'Command' )
20+ DeviceConnection = load_model ('connection' , 'DeviceConnection' )
2021command_qs = Command .objects .order_by ('-created' )
2122OrganizationUser = load_model ('openwisp_users' , 'OrganizationUser' )
2223Group = load_model ('openwisp_users' , 'Group' )
@@ -423,7 +424,7 @@ def test_post_deviceconnection_list(self):
423424 'enabled' : True ,
424425 'failure_reason' : '' ,
425426 }
426- with self .assertNumQueries (11 ):
427+ with self .assertNumQueries (12 ):
427428 response = self .client .post (path , data , content_type = 'application/json' )
428429 self .assertEqual (response .status_code , 201 )
429430
@@ -436,7 +437,7 @@ def test_post_deviceconenction_with_no_config_device(self):
436437 'enabled' : True ,
437438 'failure_reason' : '' ,
438439 }
439- with self .assertNumQueries (11 ):
440+ with self .assertNumQueries (12 ):
440441 response = self .client .post (path , data , content_type = 'application/json' )
441442 error_msg = '''
442443 the update strategy can be determined automatically only if
@@ -468,7 +469,7 @@ def test_put_devceconnection_detail(self):
468469 'enabled' : False ,
469470 'failure_reason' : '' ,
470471 }
471- with self .assertNumQueries (13 ):
472+ with self .assertNumQueries (14 ):
472473 response = self .client .put (path , data , content_type = 'application/json' )
473474 self .assertEqual (response .status_code , 200 )
474475 self .assertEqual (
@@ -482,7 +483,7 @@ def test_patch_deviceconnectoin_detail(self):
482483 path = reverse ('connection_api:deviceconnection_detail' , args = (d1 , dc .pk ))
483484 self .assertEqual (dc .update_strategy , app_settings .UPDATE_STRATEGIES [0 ][0 ])
484485 data = {'update_strategy' : app_settings .UPDATE_STRATEGIES [1 ][0 ]}
485- with self .assertNumQueries (12 ):
486+ with self .assertNumQueries (13 ):
486487 response = self .client .patch (path , data , content_type = 'application/json' )
487488 self .assertEqual (response .status_code , 200 )
488489 self .assertEqual (
@@ -501,8 +502,8 @@ def test_bearer_authentication(self):
501502 self .client .logout ()
502503 token = self ._obtain_auth_token (username = 'admin' , password = 'tester' )
503504 credentials = self ._create_credentials (auto_add = True )
504- device_conn = self ._create_device_connection ( credentials = credentials )
505- device = device_conn . device
505+ device = self ._create_config ( organization = credentials . organization ). device
506+ device_conn = device . deviceconnection_set . first ()
506507
507508 with self .subTest ('Test CredentialListCreateView' ):
508509 response = self .client .get (
0 commit comments