Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrajewski committed Jul 17, 2024
1 parent 0a25de9 commit 25d3bc5
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 56 deletions.
Empty file.
32 changes: 32 additions & 0 deletions catalystwan/integration_tests/feature_profile/sdwan/policy/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from typing import Type

from catalystwan.api.feature_profile_api import PolicyObjectFeatureProfileAPI
from catalystwan.endpoints.configuration_feature_profile import ConfigurationFeatureProfile
from catalystwan.integration_tests.base import TestCaseBase
from catalystwan.models.configuration.feature_profile.sdwan.policy_object import AnyPolicyObjectParcel


class PolicyTestCaseBase(TestCaseBase):
policy_api: PolicyObjectFeatureProfileAPI
parcel_type: Type[AnyPolicyObjectParcel]

@classmethod
def setUpClass(cls) -> None:
super().setUpClass()
cls.policy_api = cls.session.api.sdwan_feature_profiles.policy_object
cls.profile_uuid = (
ConfigurationFeatureProfile(cls.session)
.get_sdwan_feature_profiles()
.filter(profile_type="policy-object")
.single_or_default()
).profile_id

def setUp(self) -> None:
self.created_id = None
return super().setUp()

def tearDown(self) -> None:
if self.created_id:
self.policy_api.delete(self.profile_uuid, self.parcel_type, self.created_id)

return super().tearDown()
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates

from catalystwan.integration_tests.base import create_name_with_run_id
from catalystwan.integration_tests.feature_profile.sdwan.policy.base import PolicyTestCaseBase
from catalystwan.models.configuration.feature_profile.sdwan.policy_object import ExtendedCommunityParcel
from catalystwan.typed_list import DataSequence


class TestExtendedCommunityParcel(PolicyTestCaseBase):
parcel_type = ExtendedCommunityParcel

def test_get_all_parcels(self):
parcels = self.policy_api.get(self.profile_uuid, self.parcel_type)
assert type(parcels) is DataSequence

def test_create_extended_community_parcel(self):
# Arrange
parcel_name = create_name_with_run_id("ext")
ext = ExtendedCommunityParcel(parcel_name=parcel_name)
ext.add_route_target_community(100, 2000)
ext.add_route_target_community(300, 5000)
ext.add_site_of_origin_community("1.2.3.4", 1000)
ext.add_site_of_origin_community("10.20.30.40", 3000)
# Act
self.created_id = self.policy_api.create_parcel(self.profile_uuid, ext).id
parcel = self.policy_api.get(self.profile_uuid, self.parcel_type, parcel_id=self.created_id)
# Assert
assert parcel.payload.parcel_name == parcel_name
assert len(parcel.payload.entries) == 4
assert parcel.payload.entries[0].extended_community.value == "rt 100:2000"
assert parcel.payload.entries[1].extended_community.value == "rt 300:5000"
assert parcel.payload.entries[2].extended_community.value == "soo 1.2.3.4:1000"
assert parcel.payload.entries[3].extended_community.value == "soo 10.20.30.40:3000"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates
from catalystwan.integration_tests.base import create_name_with_run_id
from catalystwan.integration_tests.feature_profile.sdwan.policy.base import PolicyTestCaseBase
from catalystwan.models.configuration.feature_profile.sdwan.policy_object.security.application_list import (
SecurityApplicationListParcel,
)
from catalystwan.typed_list import DataSequence


class TestSecurityApplicationListParcelParcel(PolicyTestCaseBase):
parcel_type = SecurityApplicationListParcel

def test_get_all_parcels(self):
parcels = self.policy_api.get(self.profile_uuid, self.parcel_type)
assert type(parcels) is DataSequence

def test_createsecurity_application_list_parcel(self):
# Arrange
parcel_name = create_name_with_run_id("sal")
sal = SecurityApplicationListParcel(parcel_name=parcel_name)
sal.add_application_family("web")
sal.add_application_family("file-server")
sal.add_application_family("audio-video")
# Act
self.created_id = self.policy_api.create_parcel(self.profile_uuid, sal).id
parcel = self.policy_api.get(self.profile_uuid, self.parcel_type, parcel_id=self.created_id)
# Assert
assert parcel.payload.parcel_name == parcel_name
assert len(parcel.payload.entries) == 3
assert parcel.payload.entries[0].app_list_family.value == "web"
assert parcel.payload.entries[1].app_list_family.value == "file-server"
assert parcel.payload.entries[2].app_list_family.value == "audio-video"

This file was deleted.

0 comments on commit 25d3bc5

Please sign in to comment.