def test_dry_run( mock_get_instance_config, mock_validate_service_instance, mock_paasta_cook_image, mock_load_system_paasta_config, mock_figure_out_service_name, mock_socket_getfqdn, capsys ): mock_socket_getfqdn.return_value = 'fake_hostname' mock_get_instance_config.return_value.get_cmd.return_value = 'fake_command' mock_validate_service_instance.return_value = 'marathon' mock_paasta_cook_image.return_value = 0 mock_load_system_paasta_config.return_value = SystemPaastaConfig( {'cluster': 'fake_cluster', 'volumes': []}, '/fake_dir/') mock_figure_out_service_name.return_value = 'fake_service' # Should pass and produce something with raises(SystemExit) as excinfo: main(('local-run', '--dry-run', '--cluster', 'fake_cluster', '--instance', 'fake_instance')) ret = excinfo.value.code out, err = capsys.readouterr() assert ret == 0 # We don't care what the contents are, we just care that it is json loadable. expected_out = json.loads(out) assert isinstance(expected_out, list)
def test_paasta_version(capfd): with pytest.raises(SystemExit) as excinfo: main(('-V', )) assert excinfo.value.code == 0 out, err = capfd.readouterr() assert re.match('^paasta-tools \d+\.\d+\.\d+\n$', out)
def test_paasta_version(capsys): with pytest.raises(SystemExit) as excinfo: main(('-V',)) assert excinfo.value.code == 0 output = capsys.readouterr()[1] assert re.match('^paasta-tools \d+\.\d+\.\d+\n$', output)
def test_help(cmd, capsys): # Should pass and produce something with pytest.raises(SystemExit) as excinfo: main((cmd, '--help')) assert excinfo.value.code == 0 assert cmd in capsys.readouterr()[0]
def test_invalid_arguments_returns_non_zero(): with pytest.raises(SystemExit) as excinfo: main(('get-latest-deployment', '--herp')) assert excinfo.value.code == 1