From ddba54fae2274eda7e6109123b956ea371e09bbc Mon Sep 17 00:00:00 2001 From: mprahl Date: Apr 04 2018 15:26:13 +0000 Subject: [PATCH 1/2] Fix docstring of test_module_build_local_with_skiptests Signed-off-by: mprahl --- diff --git a/tests/test_cli.py b/tests/test_cli.py index 35fa186..5625e4a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2371,7 +2371,7 @@ State: failed @patch.object(Commands, '_run_command') def test_module_build_local_with_skiptests(self, mock_run): """ - Test submitting a local module build with parameters + Test submitting a local module build with skiptests """ file_path = os.path.join(self.cloned_repo_path, "modulemd.yaml") From 672e8b326189314b0f524db6fc912b61558810b1 Mon Sep 17 00:00:00 2001 From: mprahl Date: Apr 04 2018 15:26:18 +0000 Subject: [PATCH 2/2] Use NSVs and not build IDs with module-build-local --add-local-build Signed-off-by: mprahl --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 589b24d..50dec6f 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -2843,8 +2843,8 @@ class Commands(object): command.append('build_module_locally') if local_builds_nsvs: - for build_id in local_builds_nsvs: - command += ['--add-local-build', build_id] + for nsv in local_builds_nsvs: + command += ['--add-local-build', nsv] if skip_tests: command.append('--skiptests') diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 1bf94e2..d19a89f 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -772,8 +772,9 @@ defined, packages will be built sequentially.""" % {'name': self.name}) action='store_true', dest='skiptests') self.module_build_local_parser.add_argument( '--add-local-build', action='append', dest='local_builds_nsvs', - metavar='BUILD_ID', type=int, - help='Import previously finished local module builds into MBS') + metavar='N:S:V', + help=('Import previously finished local module builds into MBS in ' + 'the format of name:stream or name:stream:version')) self.module_build_local_parser.set_defaults( command=self.module_build_local) diff --git a/tests/test_cli.py b/tests/test_cli.py index 5625e4a..ae8c1ef 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2400,6 +2400,38 @@ State: failed '--file', file_path, '--stream', 'test']) @patch.object(Commands, '_run_command') + def test_module_build_local_with_add_local_builds(self, mock_run): + """ + Test submitting a local module build with add-local-builds + """ + + file_path = os.path.join(self.cloned_repo_path, "modulemd.yaml") + + cli_cmd = [ + 'rpkg', + '--path', self.cloned_repo_path, + 'module-build-local', + '--file', file_path, + '--stream', 'test', + '--add-local-build', 'testmodule:master:12345678', + '--add-local-build', 'testmodule2:master:12345678' + ] + mock_proc = Mock() + mock_proc.returncode = 0 + mock_run.return_value = mock_proc + with patch('sys.argv', new=cli_cmd): + cli = self.new_cli() + # we create an empty file for the purpose of this test so we don't raise an exception + open(file_path, 'a').close() + cli.module_build_local() + + mock_run.assert_called_once_with([ + 'mbs-manager', 'build_module_locally', '--add-local-build', + 'testmodule:master:12345678', '--add-local-build', + 'testmodule2:master:12345678', '--file', file_path, '--stream', + 'test']) + + @patch.object(Commands, '_run_command') def test_module_build_local_mbs_manager_is_missing(self, mock_run): mock_run.side_effect = rpkgError('[Errno 2] No such file or directory')