Skip to content

Commit

Permalink
fix portchannel test
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelmsft committed Sep 17, 2022
1 parent cac0f96 commit 273436c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/portchannel_test.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
import os
import pytest
import traceback
import mock

from click.testing import CliRunner
from jsonpatch import JsonPatchConflict

import config.main as config
import show.main as show
from utilities_common.db import Db
from mock import patch

class TestPortChannel(object):
@classmethod
def setup_class(cls):
os.environ['UTILITIES_UNIT_TESTING'] = "1"
print("SETUP")

@patch("config.main.is_portchannel_present_in_db", mock.Mock(return_value=False))
@patch("config.validated_config_db_connector.validated_set_entry", mock.Mock(side_effect=ValueError))
@mock.patch.dict(os.environ, {"ADHOC_VALIDATION": "False"})
def test_add_portchannel_with_invalid_name_yang_validation(self):
runner = CliRunner()
db = Db()
obj = {'db':db.cfgdb}

result = runner.invoke(config.config.commands["portchannel"].commands["add"], ["PortChan005"], obj=obj)
print(result.exit_code)
print(result.output)
assert result.exit_code != 0
assert "Error: PortChan005 is invalid!, name should have prefix 'PortChannel' and suffix '<0-9999>'" in result.output


def test_add_portchannel_with_invalid_name(self):
def test_add_portchannel_with_invalid_name_adhoc_validation(self):
runner = CliRunner()
db = Db()
obj = {'db':db.cfgdb}
Expand Down

0 comments on commit 273436c

Please sign in to comment.