def test_parse_args_version(self, capsys): with pytest.raises(SystemExit) as excinfo: parse_args(['-V']) assert excinfo.value.code == 0 expected = "ecsjobs v%s <%s>\n" % (VERSION, PROJECT_URL) out, err = capsys.readouterr() assert out == expected assert err == ''
def test_parse_args_jobs(self): res = parse_args([ '--only-email-if-problems', '-v', 'run', '-j', 'bar', '--job=baz' ]) assert res.verbose == 1 assert res.ACTION == 'run' assert res.SCHEDULES == [] assert res.jobs == ['bar', 'baz'] assert res.only_email_if_problems is True
def test_parse_args_run_three(self): res = parse_args(['-m', '-v', 'run', 'foo', 'bar', 'baz']) assert res.verbose == 1 assert res.ACTION == 'run' assert res.SCHEDULES == ['foo', 'bar', 'baz'] assert res.only_email_if_problems is True
def test_parse_args_run_one(self): res = parse_args(['run', 'foo']) assert res.verbose == 0 assert res.ACTION == 'run' assert res.SCHEDULES == ['foo'] assert res.only_email_if_problems is False
def test_parse_args_run_none(self): with pytest.raises(RuntimeError) as exc: parse_args(['run']) assert str(exc.value) == 'ERROR: "run" action must have one or ' \ 'more SCHEDULES specified if jobs are not ' \ 'explicitly specified with -j / --job'
def test_parse_args_validate(self): res = parse_args(['-vv', 'validate']) assert res.verbose == 2 assert res.ACTION == 'validate' assert res.SCHEDULES == [] assert res.only_email_if_problems is False
def test_parse_args_list_schedules(self): res = parse_args(['-v', 'list-schedules']) assert res.verbose == 1 assert res.ACTION == 'list-schedules' assert res.SCHEDULES == [] assert res.only_email_if_problems is False
def test_parse_args_jobs_and_schedules(self): with pytest.raises(RuntimeError) as exc: parse_args(['-v', '-j', 'bar', '--job=baz', 'run', 'foo']) assert str(exc.value) == 'ERROR: SCHEDULES cannot be mixed with ' \ '-j / --job.'