@@ -626,11 +626,11 @@ def test_deactivating_device_force_deletion(self):
626626 self .assertEqual (Device .objects .count (), 0 )
627627
628628 def test_template_create_no_org_api (self ):
629- self . assertEqual ( Template .objects .count (), 0 )
629+ initial_count = Template .objects .count ()
630630 path = reverse ("config_api:template_list" )
631631 data = self ._template_data
632632 r = self .client .post (path , data , content_type = "application/json" )
633- self .assertEqual (Template .objects .count (), 1 )
633+ self .assertEqual (Template .objects .count (), initial_count + 1 )
634634 self .assertEqual (r .status_code , 201 )
635635 self .assertEqual (r .data ["organization" ], None )
636636
@@ -649,14 +649,14 @@ def test_template_create_vpn_with_type_as_generic(self):
649649 self .assertEqual (r .status_code , 400 )
650650
651651 def test_template_create_api (self ):
652- self . assertEqual ( Template .objects .count (), 0 )
652+ initial_count = Template .objects .count ()
653653 org = self ._get_org ()
654654 path = reverse ("config_api:template_list" )
655655 data = self ._template_data
656656 data ["organization" ] = org .pk
657657 data ["required" ] = True
658658 r = self .client .post (path , data , content_type = "application/json" )
659- self .assertEqual (Template .objects .count (), 1 )
659+ self .assertEqual (Template .objects .count (), initial_count + 1 )
660660 self .assertEqual (r .status_code , 201 )
661661 self .assertEqual (r .data ["organization" ], org .pk )
662662
@@ -668,8 +668,9 @@ def test_template_create_of_vpn_type(self):
668668 data ["type" ] = "vpn"
669669 data ["vpn" ] = vpn1 .id
670670 data ["organization" ] = org .pk
671+ initial_count = Template .objects .count ()
671672 r = self .client .post (path , data , content_type = "application/json" )
672- self .assertEqual (Template .objects .count (), 1 )
673+ self .assertEqual (Template .objects .count (), initial_count + 1 )
673674 self .assertEqual (r .status_code , 201 )
674675
675676 def test_template_create_with_shared_vpn (self ):
@@ -682,9 +683,10 @@ def test_template_create_with_shared_vpn(self):
682683 data ["type" ] = "vpn"
683684 data ["vpn" ] = vpn1 .id
684685 data ["organization" ] = org1 .pk
686+ initial_count = Template .objects .count ()
685687 r = self .client .post (path , data , content_type = "application/json" )
686688 self .assertEqual (r .status_code , 201 )
687- self .assertEqual (Template .objects .count (), 1 )
689+ self .assertEqual (Template .objects .count (), initial_count + 1 )
688690 self .assertEqual (r .data ["vpn" ], vpn1 .id )
689691
690692 def test_template_creation_with_no_org_by_operator (self ):
@@ -707,12 +709,13 @@ def test_template_create_with_empty_config(self):
707709
708710 def test_template_list_api (self ):
709711 org1 = self ._get_org ()
712+ initial_count = Template .objects .count ()
710713 self ._create_template (name = "t1" , organization = org1 )
711714 path = reverse ("config_api:template_list" )
712715 with self .assertNumQueries (4 ):
713716 r = self .client .get (path )
714717 self .assertEqual (r .status_code , 200 )
715- self .assertEqual (Template .objects .count (), 1 )
718+ self .assertEqual (Template .objects .count (), initial_count + 1 )
716719
717720 def test_template_list_api_filter (self ):
718721 org1 = self ._create_org ()
@@ -840,11 +843,12 @@ def test_template_download_api(self):
840843 self .assertEqual (r .status_code , 200 )
841844
842845 def test_template_delete_api (self ):
846+ initial_count = Template .objects .count ()
843847 t1 = self ._create_template (name = "t1" )
844848 path = reverse ("config_api:template_detail" , args = [t1 .pk ])
845849 r = self .client .delete (path )
846850 self .assertEqual (r .status_code , 204 )
847- self .assertEqual (Template .objects .count (), 0 )
851+ self .assertEqual (Template .objects .count (), initial_count )
848852
849853 def test_vpn_create_api (self ):
850854 self .assertEqual (Vpn .objects .count (), 0 )
0 commit comments