Skip to content

Commit 7c3e28b

Browse files
committed
Add test for hostname setting
Signed-off-by: Yevhen Fastiuk <[email protected]>
1 parent f6d735c commit 7c3e28b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/config_test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,3 +1226,36 @@ def validate_list_checkpoints_optional_parameter(self, param_args, expected_call
12261226
self.assertTrue(expected_output in result.output)
12271227
mock_generic_updater.list_checkpoints.assert_called_once()
12281228
mock_generic_updater.list_checkpoints.assert_has_calls([expected_call])
1229+
1230+
class TestConfigHostname(object):
1231+
@classmethod
1232+
def setup_class(cls):
1233+
print("SETUP")
1234+
import config.main
1235+
importlib.reload(config.main)
1236+
1237+
@mock.patch('config.main.ConfigDBConnector')
1238+
def test_hostname_add(self, db_conn_patch, get_cmd_module):
1239+
db_conn_patch().mod_entry = mock.Mock()
1240+
(config, show) = get_cmd_module
1241+
1242+
runner = CliRunner()
1243+
result = runner.invoke(config.config.commands["hostname"],
1244+
["new_hostname"])
1245+
1246+
# Verify success
1247+
assert result.exit_code == 0
1248+
1249+
# Check was called
1250+
args_list = db_conn_patch().mod_entry.call_args_list
1251+
assert len(args_list) > 0
1252+
1253+
args, _ = args_list[0]
1254+
assert len(args) > 0
1255+
1256+
# Check new hostname was part of args
1257+
assert {'hostname': 'new_hostname'} in args
1258+
1259+
@classmethod
1260+
def teardown_class(cls):
1261+
print("TEARDOWN")

0 commit comments

Comments
 (0)