Skip to content

Commit

Permalink
EpTemplate() - remove template_name validation (#355)
Browse files Browse the repository at this point in the history
* Remove template_name validation

EpTemplate() was using FabricTypes() to validate the template_name property against a list of valid and supported fabric templates.  However, the intent of EpTemplate() is to retrieve other template types as well (network, vrf, etc), so this validation isn't ideal in this larger context.

This commit removes this validation and the associated import and instantiation of FabricTypes.

There may be associated unit-tests that need to be updated.  Will investigate and handle in a second commit if so.

* UT: Remove test_ep_templates_00050

1. Remove test_ep_templates_00050()

This test validated that a ValueError is raised if template_name is invalid.  The test for validity entailed comparing against a list of fabric template names in FabricTypes().  However, EpTemplate() is now responsible for retrieving templates that are not in this list (e.g. interface templates, etc).  Hence, this test is no longer valid.
  • Loading branch information
allenrobel authored Dec 16, 2024
1 parent 7b8775e commit 904144d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import logging

from ..config import Config
from ........fabric.fabric_types import FabricTypes


class Templates(Config):
Expand All @@ -39,7 +38,6 @@ def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
self.fabric_types = FabricTypes()

self.templates = f"{self.config}/templates"
self._template_name = None
Expand Down Expand Up @@ -71,13 +69,6 @@ def template_name(self):

@template_name.setter
def template_name(self, value):
method_name = inspect.stack()[0][3]
if value not in self.fabric_types.valid_fabric_template_names:
msg = f"{self.class_name}.{method_name}: "
msg += f"Invalid template_name: {value}. "
msg += "Expected one of: "
msg += f"{', '.join(self.fabric_types.valid_fabric_template_names)}."
raise ValueError(msg)
self._template_name = value


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,6 @@ def test_ep_templates_00040():
instance.path # pylint: disable=pointless-statement


def test_ep_templates_00050():
"""
### Class
- EpFabricConfigDeploy
### Summary
- Verify ``ValueError`` is raised if ``template_name``
is invalid.
"""
template_name = "Invalid_Template_Name"
with does_not_raise():
instance = EpTemplate()
match = r"EpTemplate.template_name:\s+"
match += r"Invalid template_name: Invalid_Template_Name.\s+"
match += r"Expected one of:\s+"
with pytest.raises(ValueError, match=match):
instance.template_name = template_name # pylint: disable=pointless-statement


def test_ep_templates_00100():
"""
### Class
Expand Down

0 comments on commit 904144d

Please sign in to comment.