def test_parse_args_retry(self): args = trigger.parse_args('-a foo -p bar -t ref proj'.split()) assert args.retry is False assert args.pid is None args = trigger.parse_args('-a foo -p bar -t ref --pid 123 proj'.split()) assert args.retry is False assert args.pid == 123 args = trigger.parse_args('-a foo -p bar -t ref -r --pid 123 proj'.split()) assert args.retry is True assert args.pid == 123
def test_args_1(self): args = trigger.parse_args( '-p ptok -t ref -e foo-1=bar2 -e foo2=bar3 proj'.split()) assert args.pipeline_token == 'ptok' assert args.target_ref == 'ref' assert args.env == ['foo-1=bar2', 'foo2=bar3'] assert args.project_id == 'proj'
def test_args_2(self): with pytest.raises(SystemExit): trigger.parse_args( '-a foo -e foo1=bar2 foo2=bar3 dangling'.split())
def test_args_verify_ssl_invalid(self): temp_stderr = StringIO() with contextlib.redirect_stderr(temp_stderr), self.assertRaises(SystemExit) as context: trigger.parse_args("-p tok -t ref -v some_value 123".split()) assert context.exception and isinstance(context.exception, SystemExit) and context.exception.code == 2 assert 'argument -v/--verifyssl: Boolean value expected' in temp_stderr.getvalue().strip()
def test_args_verify_ssl_short(self): args = trigger.parse_args("-p tok -t ref -v true 123".split()) assert args.verifyssl
def test_args_verify_ssl(self): args = trigger.parse_args("-p tok -t ref --verifyssl false 123".split()) assert not args.verifyssl
def test_args_required(self): temp_stderr = StringIO() with contextlib.redirect_stderr(temp_stderr), self.assertRaises(SystemExit) as context: trigger.parse_args('-a foo -e foo1=bar2 foo2=bar3 dangling'.split()) assert context.exception and isinstance(context.exception, SystemExit) and context.exception.code == 2 assert 'the following arguments are required: -p/--pipeline-token, -t/--target-ref' in temp_stderr.getvalue().strip()