Пример #1
0
def test_cancel_build_no_config(mock_cc, capsys):
    mock_cc.create_from_file_config.side_effect = CoprNoConfException()

    with pytest.raises(SystemExit) as err:
        main.main(argv=["cancel", "123400"])

    assert err.value.code == 6
    out, err = capsys.readouterr()
    assert ("Error: Operation requires api authentication\n"
            "File `~/.config/copr` is missing or incorrect\n") in out

    expected_warning = no_config_warning.format("~/.config/copr")
    assert expected_warning in out
Пример #2
0
def test_cancel_build_no_config(mock_cc, capsys):
    mock_cc.create_from_file_config.side_effect = CoprNoConfException()

    with pytest.raises(SystemExit) as err:
        main.main(argv=["cancel", "123400"])

    assert err.value.code == 6
    out, err = capsys.readouterr()

    assert "Error: Operation requires api authentication" in err
    assert "File '~/.config/copr' is missing or incorrect" in err

    expected_warning = no_config_warning.format("~/.config/copr")
    assert expected_warning in err
Пример #3
0
def test_cancel_build_no_config(config_from_file, capsys):
    config_from_file.side_effect = copr.v3.CoprNoConfigException("Dude, your config is missing")

    with pytest.raises(SystemExit) as err:
        main.main(argv=["cancel", "123400"])

    assert exit_wrap(err.value) == 6
    out, err = capsys.readouterr()

    assert "Error: Operation requires api authentication" in err
    assert "File '~/.config/copr' is missing or incorrect" in err

    expected_warning = no_config_warning.format("~/.config/copr", "Dude, your config is missing")
    assert expected_warning in err
Пример #4
0
def test_list_project(get_list, config_from_file, capsys):
    response_data = json.loads(read_res('list_projects_response.json'))
    expected_output = read_res('list_projects_expected.txt')

    # no config
    config_from_file.side_effect = copr.v3.CoprNoConfigException("Dude, your config is missing")
    control_response = [Munch(x) for x in response_data]
    get_list.return_value = control_response

    main.main(argv=["list", "rhscl"])
    out, err = capsys.readouterr()
    assert expected_output in out

    expected_warning = no_config_warning.format("~/.config/copr", "Dude, your config is missing")
    assert expected_warning in err
Пример #5
0
def test_list_project(mock_cc, capsys):
    response_data = json.loads(read_res('list_projects_response.json'))
    expected_output = read_res('list_projects_expected.txt')

    # no config
    mock_cc.create_from_file_config.side_effect = CoprNoConfException()
    mocked_client = MagicMock(CoprClient(no_config=True))

    control_response = CoprResponse(client=None, method="", data=response_data,
                                    parsers=[ProjectListParser, CommonMsgErrorOutParser])
    mocked_client.get_projects_list.return_value = control_response
    mock_cc.return_value = mocked_client

    main.main(argv=["list", "rhscl"])

    out, err = capsys.readouterr()
    assert expected_output in out

    expected_warning = no_config_warning.format("~/.config/copr")
    assert expected_warning in out
Пример #6
0
def test_list_project(mock_cc, capsys):
    response_data = json.loads(read_res('list_projects_response.json'))
    expected_output = read_res('list_projects_expected.txt')

    # no config
    mock_cc.create_from_file_config.side_effect = CoprNoConfException()
    mocked_client = MagicMock(CoprClient(no_config=True))

    control_response = CoprResponse(
        client=None,
        method="",
        data=response_data,
        parsers=[ProjectListParser, CommonMsgErrorOutParser])
    mocked_client.get_projects_list.return_value = control_response
    mock_cc.return_value = mocked_client

    main.main(argv=["list", "rhscl"])

    out, err = capsys.readouterr()
    assert expected_output in out

    expected_warning = no_config_warning.format("~/.config/copr")
    assert expected_warning in err