@@ -652,18 +652,36 @@ def test_remove_duplicate_files(self):
652
652
]
653
653
},
654
654
)
655
- config = self ._create_config (organization = self ._get_org ())
656
- config .templates .add (template1 )
657
- config .templates .add (template2 )
658
- config .refresh_from_db ()
659
- try :
660
- result = config .get_backend_instance (
661
- template_instances = [template1 , template2 ]
662
- ).render ()
663
- except ValidationError :
664
- self .fail ('ValidationError raised!' )
665
- else :
666
- self .assertIn ('# path: /etc/vpnserver1' , result )
655
+ org = self ._get_org ()
656
+ with self .subTest ('Test template applied on creating config' ):
657
+ try :
658
+ config = self ._create_config (
659
+ organization = org ,
660
+ templates = [template1 , template2 ],
661
+ )
662
+ result = config .get_backend_instance (
663
+ template_instances = [template1 , template2 ]
664
+ ).render ()
665
+ except ValidationError :
666
+ self .fail ('ValidationError raised!' )
667
+ else :
668
+ self .assertIn ('# path: /etc/vpnserver1' , result )
669
+
670
+ config .device .delete ()
671
+ config .delete ()
672
+ with self .subTest ('Test template applied after creating config object' ):
673
+ config = self ._create_config (organization = org )
674
+ config .templates .add (template1 )
675
+ config .templates .add (template2 )
676
+ config .refresh_from_db ()
677
+ try :
678
+ result = config .get_backend_instance (
679
+ template_instances = [template1 , template2 ]
680
+ ).render ()
681
+ except ValidationError :
682
+ self .fail ('ValidationError raised!' )
683
+ else :
684
+ self .assertIn ('# path: /etc/vpnserver1' , result )
667
685
668
686
def test_duplicated_files_in_config (self ):
669
687
try :
0 commit comments