@@ -249,7 +249,7 @@ def test_device_create_with_devicegroup(self):
249249 def test_device_list_api (self ):
250250 device = self ._create_device ()
251251 path = reverse ("config_api:device_list" )
252- with self .assertNumQueries (4 ):
252+ with self .assertNumQueries (3 ):
253253 r = self .client .get (path )
254254 self .assertEqual (r .status_code , 200 )
255255 with self .subTest ("device list should show most recent first" ):
@@ -395,7 +395,7 @@ def test_device_filter_templates(self):
395395 def test_device_detail_api (self ):
396396 d1 = self ._create_device ()
397397 path = reverse ("config_api:device_detail" , args = [d1 .pk ])
398- with self .assertNumQueries (3 ):
398+ with self .assertNumQueries (2 ):
399399 r = self .client .get (path )
400400 self .assertEqual (r .status_code , 200 )
401401 self .assertEqual (r .data ["config" ], None )
@@ -405,7 +405,7 @@ def test_device_detail_config_api(self):
405405 d1 = self ._create_device ()
406406 self ._create_config (device = d1 )
407407 path = reverse ("config_api:device_detail" , args = [d1 .pk ])
408- with self .assertNumQueries (4 ):
408+ with self .assertNumQueries (3 ):
409409 r = self .client .get (path )
410410 self .assertEqual (r .status_code , 200 )
411411 self .assertNotEqual (r .data ["config" ], None )
@@ -547,7 +547,7 @@ def test_device_download_api(self):
547547 d1 = self ._create_device ()
548548 self ._create_config (device = d1 )
549549 path = reverse ("config_api:download_device_config" , args = [d1 .pk ])
550- with self .assertNumQueries (8 ):
550+ with self .assertNumQueries (7 ):
551551 r = self .client .get (path )
552552 self .assertEqual (r .status_code , 200 )
553553
@@ -708,7 +708,7 @@ def test_template_list_api(self):
708708 org1 = self ._get_org ()
709709 self ._create_template (name = "t1" , organization = org1 )
710710 path = reverse ("config_api:template_list" )
711- with self .assertNumQueries (5 ):
711+ with self .assertNumQueries (4 ):
712712 r = self .client .get (path )
713713 self .assertEqual (r .status_code , 200 )
714714 self .assertEqual (Template .objects .count (), 1 )
@@ -801,7 +801,7 @@ def test_template_list_for_shared_objects(self):
801801 def test_template_detail_api (self ):
802802 t1 = self ._create_template (name = "t1" )
803803 path = reverse ("config_api:template_detail" , args = [t1 .pk ])
804- with self .assertNumQueries (4 ):
804+ with self .assertNumQueries (3 ):
805805 r = self .client .get (path )
806806 self .assertEqual (r .status_code , 200 )
807807 self .assertEqual (r .data ["organization" ], None )
@@ -834,7 +834,7 @@ def test_template_patch_api(self):
834834 def test_template_download_api (self ):
835835 t1 = self ._create_template (name = "t1" )
836836 path = reverse ("config_api:download_template_config" , args = [t1 .pk ])
837- with self .assertNumQueries (3 ):
837+ with self .assertNumQueries (2 ):
838838 r = self .client .get (path )
839839 self .assertEqual (r .status_code , 200 )
840840
@@ -873,7 +873,7 @@ def test_vpn_list_api(self):
873873 org = self ._get_org ()
874874 self ._create_vpn (organization = org )
875875 path = reverse ("config_api:vpn_list" )
876- with self .assertNumQueries (4 ):
876+ with self .assertNumQueries (3 ):
877877 r = self .client .get (path )
878878 self .assertEqual (r .status_code , 200 )
879879
@@ -935,7 +935,7 @@ def test_vpn_list_for_shared_objects(self):
935935 def test_vpn_detail_no_org_api (self ):
936936 vpn1 = self ._create_vpn (name = "test-vpn" )
937937 path = reverse ("config_api:vpn_detail" , args = [vpn1 .pk ])
938- with self .assertNumQueries (3 ):
938+ with self .assertNumQueries (2 ):
939939 r = self .client .get (path )
940940 self .assertEqual (r .status_code , 200 )
941941 self .assertEqual (r .data ["organization" ], None )
@@ -945,7 +945,7 @@ def test_vpn_detail_with_org_api(self):
945945 org = self ._get_org ()
946946 vpn1 = self ._create_vpn (name = "test-vpn" , organization = org )
947947 path = reverse ("config_api:vpn_detail" , args = [vpn1 .pk ])
948- with self .assertNumQueries (3 ):
948+ with self .assertNumQueries (2 ):
949949 r = self .client .get (path )
950950 self .assertEqual (r .status_code , 200 )
951951 self .assertEqual (r .data ["organization" ], org .pk )
@@ -980,7 +980,7 @@ def test_vpn_patch_api(self):
980980 def test_vpn_download_api (self ):
981981 vpn1 = self ._create_vpn (name = "test-vpn" )
982982 path = reverse ("config_api:download_vpn_config" , args = [vpn1 .pk ])
983- with self .assertNumQueries (5 ):
983+ with self .assertNumQueries (4 ):
984984 r = self .client .get (path )
985985 self .assertEqual (r .status_code , 200 )
986986
@@ -1054,7 +1054,7 @@ def test_devicegroup_list_api(self):
10541054 dg = self ._create_device_group ()
10551055 path = reverse ("config_api:devicegroup_list" )
10561056 with self .subTest ("assert number of queries" ):
1057- with self .assertNumQueries (5 ):
1057+ with self .assertNumQueries (4 ):
10581058 r = self .client .get (path )
10591059 self .assertEqual (r .status_code , 200 )
10601060 with self .subTest ("should not contain default or required templates" ):
@@ -1123,7 +1123,7 @@ def test_devicegroup_detail_api(self):
11231123 path = reverse ("config_api:devicegroup_detail" , args = [device_group .pk ])
11241124
11251125 with self .subTest ("Test GET" ):
1126- with self .assertNumQueries (4 ):
1126+ with self .assertNumQueries (3 ):
11271127 response = self .client .get (path )
11281128 self .assertEqual (response .status_code , 200 )
11291129 self .assertEqual (response .data ["name" ], device_group .name )
@@ -1354,11 +1354,11 @@ def _build_cache(path, org_slug):
13541354 self .assertEqual (response .status_code , 200 )
13551355
13561356 def _assert_cache_invalidation (path , org_slug ):
1357- with self .assertNumQueries (6 ):
1357+ with self .assertNumQueries (5 ):
13581358 response = self .client .get (path , data = {"org" : org_slug })
13591359 self .assertEqual (response .status_code , 200 )
13601360
1361- with self .assertNumQueries (6 ):
1361+ with self .assertNumQueries (5 ):
13621362 response = self .client .get (path )
13631363 self .assertEqual (response .status_code , 200 )
13641364
@@ -1369,11 +1369,11 @@ def _assert_cache_invalidation(path, org_slug):
13691369
13701370 with self .subTest ("Test caching works" ):
13711371 _build_cache (path , org .slug )
1372- with self .assertNumQueries (3 ):
1372+ with self .assertNumQueries (2 ):
13731373 response = self .client .get (path , data = {"org" : org .slug })
13741374 self .assertEqual (response .status_code , 200 )
13751375
1376- with self .assertNumQueries (3 ):
1376+ with self .assertNumQueries (2 ):
13771377 response = self .client .get (path )
13781378 self .assertEqual (response .status_code , 200 )
13791379
@@ -1415,11 +1415,11 @@ def test_devicegroup_commonname_cache_invalidates_on_devicegroup_delete(self):
14151415 "config_api:devicegroup_x509_commonname" , args = [cert .common_name ]
14161416 )
14171417
1418- with self .assertNumQueries (6 ):
1418+ with self .assertNumQueries (5 ):
14191419 response = self .client .get (path , data = {"org" : org .slug })
14201420 self .assertEqual (response .status_code , 200 )
14211421
1422- with self .assertNumQueries (3 ):
1422+ with self .assertNumQueries (2 ):
14231423 response = self .client .get (path , data = {"org" : org .slug })
14241424 self .assertEqual (response .status_code , 200 )
14251425
@@ -1433,11 +1433,11 @@ def test_devicegroup_commonname_cache_invalidates_on_organization_delete(self):
14331433 "config_api:devicegroup_x509_commonname" , args = [cert .common_name ]
14341434 )
14351435
1436- with self .assertNumQueries (6 ):
1436+ with self .assertNumQueries (5 ):
14371437 response = self .client .get (path , data = {"org" : org .slug })
14381438 self .assertEqual (response .status_code , 200 )
14391439
1440- with self .assertNumQueries (3 ):
1440+ with self .assertNumQueries (2 ):
14411441 response = self .client .get (path , data = {"org" : org .slug })
14421442 self .assertEqual (response .status_code , 200 )
14431443
@@ -1451,11 +1451,11 @@ def test_devicegroup_commonname_cache_invalidates_on_cert_delete(self):
14511451 "config_api:devicegroup_x509_commonname" , args = [cert .common_name ]
14521452 )
14531453
1454- with self .assertNumQueries (6 ):
1454+ with self .assertNumQueries (5 ):
14551455 response = self .client .get (path , data = {"org" : org .slug })
14561456 self .assertEqual (response .status_code , 200 )
14571457
1458- with self .assertNumQueries (3 ):
1458+ with self .assertNumQueries (2 ):
14591459 response = self .client .get (path , data = {"org" : org .slug })
14601460 self .assertEqual (response .status_code , 200 )
14611461
0 commit comments