From 5899db9080cea50806454d5b7fbdd9c1d16ae0fe Mon Sep 17 00:00:00 2001 From: isabelmsft Date: Tue, 1 Nov 2022 06:28:41 +0000 Subject: [PATCH] fix UT --- tests/aaa_test.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/aaa_test.py b/tests/aaa_test.py index 80f9baa301..e554937e1f 100644 --- a/tests/aaa_test.py +++ b/tests/aaa_test.py @@ -294,7 +294,17 @@ def test_config_aaa_tacacs_delete_yang_validation(self): result = runner.invoke(config.config.commands["tacacs"].commands["delete"], ["10.10.10.10"], obj=obj) print(result.exit_code) - print(result.output) assert result.exit_code != 0 - assert "Invalid ip address. Error:" in result.output + @patch("validated_config_db_connector.device_info.is_yang_config_validation_enabled", mock.Mock(return_value=True)) + @patch("config.validated_config_db_connector.ValidatedConfigDBConnector.validated_set_entry", mock.Mock(side_effect=ValueError)) + @patch("config.main.ConfigDBConnector.get_entry", mock.Mock(return_value={})) + def test_config_aaa_tacacs_add_yang_validation(self): + config.ADHOC_VALIDATION = True + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["tacacs"].commands["add"], ["10.10.10.10"], obj=obj) + print(result.exit_code) + assert result.exit_code != 0