@@ -249,7 +249,7 @@ def test_device_create_with_devicegroup(self):
249
249
def test_device_list_api (self ):
250
250
device = self ._create_device ()
251
251
path = reverse ("config_api:device_list" )
252
- with self .assertNumQueries (4 ):
252
+ with self .assertNumQueries (3 ):
253
253
r = self .client .get (path )
254
254
self .assertEqual (r .status_code , 200 )
255
255
with self .subTest ("device list should show most recent first" ):
@@ -395,7 +395,7 @@ def test_device_filter_templates(self):
395
395
def test_device_detail_api (self ):
396
396
d1 = self ._create_device ()
397
397
path = reverse ("config_api:device_detail" , args = [d1 .pk ])
398
- with self .assertNumQueries (3 ):
398
+ with self .assertNumQueries (2 ):
399
399
r = self .client .get (path )
400
400
self .assertEqual (r .status_code , 200 )
401
401
self .assertEqual (r .data ["config" ], None )
@@ -405,7 +405,7 @@ def test_device_detail_config_api(self):
405
405
d1 = self ._create_device ()
406
406
self ._create_config (device = d1 )
407
407
path = reverse ("config_api:device_detail" , args = [d1 .pk ])
408
- with self .assertNumQueries (4 ):
408
+ with self .assertNumQueries (3 ):
409
409
r = self .client .get (path )
410
410
self .assertEqual (r .status_code , 200 )
411
411
self .assertNotEqual (r .data ["config" ], None )
@@ -547,7 +547,7 @@ def test_device_download_api(self):
547
547
d1 = self ._create_device ()
548
548
self ._create_config (device = d1 )
549
549
path = reverse ("config_api:download_device_config" , args = [d1 .pk ])
550
- with self .assertNumQueries (8 ):
550
+ with self .assertNumQueries (7 ):
551
551
r = self .client .get (path )
552
552
self .assertEqual (r .status_code , 200 )
553
553
@@ -708,7 +708,7 @@ def test_template_list_api(self):
708
708
org1 = self ._get_org ()
709
709
self ._create_template (name = "t1" , organization = org1 )
710
710
path = reverse ("config_api:template_list" )
711
- with self .assertNumQueries (5 ):
711
+ with self .assertNumQueries (4 ):
712
712
r = self .client .get (path )
713
713
self .assertEqual (r .status_code , 200 )
714
714
self .assertEqual (Template .objects .count (), 1 )
@@ -801,7 +801,7 @@ def test_template_list_for_shared_objects(self):
801
801
def test_template_detail_api (self ):
802
802
t1 = self ._create_template (name = "t1" )
803
803
path = reverse ("config_api:template_detail" , args = [t1 .pk ])
804
- with self .assertNumQueries (4 ):
804
+ with self .assertNumQueries (3 ):
805
805
r = self .client .get (path )
806
806
self .assertEqual (r .status_code , 200 )
807
807
self .assertEqual (r .data ["organization" ], None )
@@ -834,7 +834,7 @@ def test_template_patch_api(self):
834
834
def test_template_download_api (self ):
835
835
t1 = self ._create_template (name = "t1" )
836
836
path = reverse ("config_api:download_template_config" , args = [t1 .pk ])
837
- with self .assertNumQueries (3 ):
837
+ with self .assertNumQueries (2 ):
838
838
r = self .client .get (path )
839
839
self .assertEqual (r .status_code , 200 )
840
840
@@ -873,7 +873,7 @@ def test_vpn_list_api(self):
873
873
org = self ._get_org ()
874
874
self ._create_vpn (organization = org )
875
875
path = reverse ("config_api:vpn_list" )
876
- with self .assertNumQueries (4 ):
876
+ with self .assertNumQueries (3 ):
877
877
r = self .client .get (path )
878
878
self .assertEqual (r .status_code , 200 )
879
879
@@ -935,7 +935,7 @@ def test_vpn_list_for_shared_objects(self):
935
935
def test_vpn_detail_no_org_api (self ):
936
936
vpn1 = self ._create_vpn (name = "test-vpn" )
937
937
path = reverse ("config_api:vpn_detail" , args = [vpn1 .pk ])
938
- with self .assertNumQueries (3 ):
938
+ with self .assertNumQueries (2 ):
939
939
r = self .client .get (path )
940
940
self .assertEqual (r .status_code , 200 )
941
941
self .assertEqual (r .data ["organization" ], None )
@@ -945,7 +945,7 @@ def test_vpn_detail_with_org_api(self):
945
945
org = self ._get_org ()
946
946
vpn1 = self ._create_vpn (name = "test-vpn" , organization = org )
947
947
path = reverse ("config_api:vpn_detail" , args = [vpn1 .pk ])
948
- with self .assertNumQueries (3 ):
948
+ with self .assertNumQueries (2 ):
949
949
r = self .client .get (path )
950
950
self .assertEqual (r .status_code , 200 )
951
951
self .assertEqual (r .data ["organization" ], org .pk )
@@ -980,7 +980,7 @@ def test_vpn_patch_api(self):
980
980
def test_vpn_download_api (self ):
981
981
vpn1 = self ._create_vpn (name = "test-vpn" )
982
982
path = reverse ("config_api:download_vpn_config" , args = [vpn1 .pk ])
983
- with self .assertNumQueries (5 ):
983
+ with self .assertNumQueries (4 ):
984
984
r = self .client .get (path )
985
985
self .assertEqual (r .status_code , 200 )
986
986
@@ -1054,7 +1054,7 @@ def test_devicegroup_list_api(self):
1054
1054
dg = self ._create_device_group ()
1055
1055
path = reverse ("config_api:devicegroup_list" )
1056
1056
with self .subTest ("assert number of queries" ):
1057
- with self .assertNumQueries (5 ):
1057
+ with self .assertNumQueries (4 ):
1058
1058
r = self .client .get (path )
1059
1059
self .assertEqual (r .status_code , 200 )
1060
1060
with self .subTest ("should not contain default or required templates" ):
@@ -1123,7 +1123,7 @@ def test_devicegroup_detail_api(self):
1123
1123
path = reverse ("config_api:devicegroup_detail" , args = [device_group .pk ])
1124
1124
1125
1125
with self .subTest ("Test GET" ):
1126
- with self .assertNumQueries (4 ):
1126
+ with self .assertNumQueries (3 ):
1127
1127
response = self .client .get (path )
1128
1128
self .assertEqual (response .status_code , 200 )
1129
1129
self .assertEqual (response .data ["name" ], device_group .name )
@@ -1354,11 +1354,11 @@ def _build_cache(path, org_slug):
1354
1354
self .assertEqual (response .status_code , 200 )
1355
1355
1356
1356
def _assert_cache_invalidation (path , org_slug ):
1357
- with self .assertNumQueries (6 ):
1357
+ with self .assertNumQueries (5 ):
1358
1358
response = self .client .get (path , data = {"org" : org_slug })
1359
1359
self .assertEqual (response .status_code , 200 )
1360
1360
1361
- with self .assertNumQueries (6 ):
1361
+ with self .assertNumQueries (5 ):
1362
1362
response = self .client .get (path )
1363
1363
self .assertEqual (response .status_code , 200 )
1364
1364
@@ -1369,11 +1369,11 @@ def _assert_cache_invalidation(path, org_slug):
1369
1369
1370
1370
with self .subTest ("Test caching works" ):
1371
1371
_build_cache (path , org .slug )
1372
- with self .assertNumQueries (3 ):
1372
+ with self .assertNumQueries (2 ):
1373
1373
response = self .client .get (path , data = {"org" : org .slug })
1374
1374
self .assertEqual (response .status_code , 200 )
1375
1375
1376
- with self .assertNumQueries (3 ):
1376
+ with self .assertNumQueries (2 ):
1377
1377
response = self .client .get (path )
1378
1378
self .assertEqual (response .status_code , 200 )
1379
1379
@@ -1415,11 +1415,11 @@ def test_devicegroup_commonname_cache_invalidates_on_devicegroup_delete(self):
1415
1415
"config_api:devicegroup_x509_commonname" , args = [cert .common_name ]
1416
1416
)
1417
1417
1418
- with self .assertNumQueries (6 ):
1418
+ with self .assertNumQueries (5 ):
1419
1419
response = self .client .get (path , data = {"org" : org .slug })
1420
1420
self .assertEqual (response .status_code , 200 )
1421
1421
1422
- with self .assertNumQueries (3 ):
1422
+ with self .assertNumQueries (2 ):
1423
1423
response = self .client .get (path , data = {"org" : org .slug })
1424
1424
self .assertEqual (response .status_code , 200 )
1425
1425
@@ -1433,11 +1433,11 @@ def test_devicegroup_commonname_cache_invalidates_on_organization_delete(self):
1433
1433
"config_api:devicegroup_x509_commonname" , args = [cert .common_name ]
1434
1434
)
1435
1435
1436
- with self .assertNumQueries (6 ):
1436
+ with self .assertNumQueries (5 ):
1437
1437
response = self .client .get (path , data = {"org" : org .slug })
1438
1438
self .assertEqual (response .status_code , 200 )
1439
1439
1440
- with self .assertNumQueries (3 ):
1440
+ with self .assertNumQueries (2 ):
1441
1441
response = self .client .get (path , data = {"org" : org .slug })
1442
1442
self .assertEqual (response .status_code , 200 )
1443
1443
@@ -1451,11 +1451,11 @@ def test_devicegroup_commonname_cache_invalidates_on_cert_delete(self):
1451
1451
"config_api:devicegroup_x509_commonname" , args = [cert .common_name ]
1452
1452
)
1453
1453
1454
- with self .assertNumQueries (6 ):
1454
+ with self .assertNumQueries (5 ):
1455
1455
response = self .client .get (path , data = {"org" : org .slug })
1456
1456
self .assertEqual (response .status_code , 200 )
1457
1457
1458
- with self .assertNumQueries (3 ):
1458
+ with self .assertNumQueries (2 ):
1459
1459
response = self .client .get (path , data = {"org" : org .slug })
1460
1460
self .assertEqual (response .status_code , 200 )
1461
1461
0 commit comments