def test_should_raise_exception_when_error_occurred_in_output(self, mocked_output): helper = YangLoaderHelper() mocked_output.return_value = "abcd ERR" with self.assertRaises(RuntimeError) as context: helper._run_bash_command("sample command") self.assertEqual('abcd ERR', str(context.exception))
def test_should_verify_change_listener_for_model_properly(self, mocked_output, mocked_popen): helper = YangLoaderHelper() helper.start_change_listener_for_model("sampleModule") mocked_output.assert_called_with( ['pgrep', '-f', '/opt/dev/netopeer-change-saver/bin/netopeer-change-saver sampleModule kafka1 config'], stderr=-2, universal_newlines=True)
def test_should_delete_yang_model(self, mocked_output): helper = YangLoaderHelper() helper.uninstall_a_model("modelName") mocked_output.assert_called_with( ['sysrepoctl', '--uninstall', '--module=modelName'], stderr=-2, universal_newlines=True)
def test_should_set_default_configuration(self, mocked_output): helper = YangLoaderHelper() helper.set_default_configuration("samplePath", "sampleModuleName") mocked_output.assert_called_with( ['sysrepocfg', '--import=samplePath', '--datastore=startup', '--format=xml', '--level=3', 'sampleModuleName'], stderr=-2, universal_newlines=True)
def test_should_install_new_yang_model(self, mocked_output): helper = YangLoaderHelper() helper.install_new_model("path") mocked_output.assert_called_with( ['sysrepoctl', '--install', '--yang=path', '--owner=netconf:nogroup', '--permissions=777'], stderr=-2, universal_newlines=True)
def test_should_save_file_and_return_path(self): helper = YangLoaderHelper() mocked_file = mock.Mock(FileStorage) mocked_file.filename = "sample" path = helper.save_file(mocked_file) self.assertEqual(path, "/tmp/sample") mocked_file.save.assert_called_once_with("/tmp/sample")