This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move function flatten_general_templates to DeviceTemplate model.
- Loading branch information
1 parent
7dbffb2
commit e9d4ad5
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
catalystwan/tests/templates/test_flatten_general_templates.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import unittest | ||
|
||
from catalystwan.api.templates.device_template.device_template import DeviceTemplate, GeneralTemplate | ||
|
||
|
||
class TestFlattenGeneralTemplates(unittest.TestCase): | ||
def setUp(self): | ||
self.device_template = DeviceTemplate( | ||
template_name="DT-example", | ||
template_description="DT-example", | ||
device_role="None", | ||
device_type="None", | ||
security_policy_id="None", | ||
policy_id="None", | ||
generalTemplates=[ | ||
GeneralTemplate( | ||
name="1level", | ||
templateId="1", | ||
templateType="1", | ||
subTemplates=[ | ||
GeneralTemplate( | ||
name="2level", | ||
templateId="2", | ||
templateType="2", | ||
subTemplates=[GeneralTemplate(name="3level", templateId="3", templateType="3")], | ||
) | ||
], | ||
) | ||
], | ||
) | ||
|
||
def test_flatten_general_templates(self): | ||
self.assertEqual( | ||
self.device_template.get_flattened_general_templates(), | ||
[ | ||
GeneralTemplate( | ||
name="1level", | ||
templateId="1", | ||
templateType="1", | ||
), | ||
GeneralTemplate( | ||
name="2level", | ||
templateId="2", | ||
templateType="2", | ||
), | ||
GeneralTemplate(name="3level", templateId="3", templateType="3"), | ||
], | ||
) |