| |
@@ -639,6 +639,30 @@
|
| |
@patch('sys.stderr', new=StringIO())
|
| |
@patch('pyrpkg.Commands._clone_config', new_callable=Mock())
|
| |
@patch('pyrpkg.Commands._run_command')
|
| |
+ def test_extra_args_copr(self, _run_command, _clone_config):
|
| |
+ # copr-build is the command that has two subcommands (rpmbuild and copr-cli)
|
| |
+ # that might accept the extra args. This tests requies extra_args at copr-cli.
|
| |
+ cli_cmd = ['rpkg', '--user', 'dude', '--path', self.cloned_repo_path,
|
| |
+ '--release', 'rhel-6', 'copr-build', 'COPR-REPO',
|
| |
+ '--', '--after-build-id', 'ID']
|
| |
+
|
| |
+ with patch('sys.argv', new=cli_cmd):
|
| |
+ cli = self.new_cli()
|
| |
+ cli.copr_build()
|
| |
+
|
| |
+ expected_cmd = ['copr-cli', 'build', '--after-build-id', 'ID', 'COPR-REPO']
|
| |
+ self.assertEqual(2, _run_command.call_count)
|
| |
+ copr_cli_call = _run_command.mock_calls[1]
|
| |
+ if 'args' in dir(copr_cli_call): # doesn't work in <=py36
|
| |
+ # strip the last argument - it contains dynamically generated src.rpm filename
|
| |
+ self.assertEqual(expected_cmd, copr_cli_call.args[0][:-1])
|
| |
+
|
| |
+ output = sys.stderr.getvalue().strip()
|
| |
+ self.assertEqual('', output)
|
| |
+
|
| |
+ @patch('sys.stderr', new=StringIO())
|
| |
+ @patch('pyrpkg.Commands._clone_config', new_callable=Mock())
|
| |
+ @patch('pyrpkg.Commands._run_command')
|
| |
def test_extra_args_incorrect(self, _run_command, _clone_config):
|
| |
"""Missing '--' separator between standard arguments and extra
|
| |
arguments. This can be valid command but might have different
|
| |
The right target for passing extra_args (arguments that are placed
after '--' on the command line) is the command copr-cli instead
of rpmbuild command.
Fixes: https://pagure.io/fedpkg/issue/510
JIRA: RHELCMP-11429
Signed-off-by: Ondrej Nosek onosek@redhat.com