This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add converter * Add unit tests * Fix unit tests * Fix docstring
- Loading branch information
1 parent
cbd278b
commit 477ab77
Showing
3 changed files
with
89 additions
and
4 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
53 changes: 53 additions & 0 deletions
53
catalystwan/tests/config_migration/policy_converters/test_aspath.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,53 @@ | ||
import unittest | ||
|
||
from catalystwan.models.configuration.config_migration import PolicyConvertContext | ||
from catalystwan.models.configuration.feature_profile.sdwan.policy_object.policy.as_path import AsPathParcel | ||
from catalystwan.models.policy.list.as_path import ASPathList, ASPathListEntry | ||
from catalystwan.utils.config_migration.converters.policy.policy_lists import convert | ||
|
||
|
||
class TestAsPathConverter(unittest.TestCase): | ||
def setUp(self) -> None: | ||
self.context = PolicyConvertContext() | ||
|
||
def test_aspath_with_name_conversion(self): | ||
# Arrange | ||
name = "aspath" | ||
description = "aspath description" | ||
entry_1 = "600008" | ||
entry_2 = "600009" | ||
entry_3 = "600010" | ||
aspath = ASPathList( | ||
name=name, | ||
description=description, | ||
) | ||
for entry in [entry_1, entry_2, entry_3]: | ||
aspath._add_entry(ASPathListEntry(as_path=entry)) | ||
# Act | ||
parcel = convert(aspath, self.context).output | ||
# Assert | ||
assert isinstance(parcel, AsPathParcel) | ||
assert parcel.parcel_name == name | ||
assert parcel.parcel_description == description | ||
assert len(parcel.entries) == 3 | ||
assert parcel.entries[0].as_path.value == entry_1 | ||
assert parcel.entries[1].as_path.value == entry_2 | ||
assert parcel.entries[2].as_path.value == entry_3 | ||
assert parcel.as_path_list_num.value == self.context.as_path_list_num_mapping[name] | ||
|
||
def test_aspath_with_number_conversion(self): | ||
# Arrange | ||
name = "490" | ||
description = "aspath description" | ||
aspath = ASPathList( | ||
name=name, | ||
description=description, | ||
) | ||
# Act | ||
parcel = convert(aspath, self.context).output | ||
# Assert | ||
assert isinstance(parcel, AsPathParcel) | ||
assert parcel.parcel_name == name | ||
assert parcel.parcel_description == description | ||
assert len(parcel.entries) == 0 | ||
assert parcel.as_path_list_num.value == 490 |
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