Exemple #1
0
def test_get_archive_root_dir(archive_type, return_value, upstream_mock,
                              tar_mock):
    if archive_type == "tar":
        tar_mock(is_tarfile=True)
        flexmock(Archive).should_receive(
            "get_archive_root_dir_from_tar").and_return(
                return_value).with_args("_archive").once()
        assert (Archive(upstream_mock,
                        "").get_archive_root_dir("_archive") == return_value)
    elif archive_type == "unknown":
        flexmock(Archive).should_receive(
            "get_archive_root_dir_from_template").and_return(return_value)
        tar_mock(is_tarfile=False)
        assert (Archive(upstream_mock,
                        "").get_archive_root_dir("_archive") == return_value)
Exemple #2
0
def test_get_archive_root_dir(template, expected_output, upstream_instance):
    u, ups = upstream_instance
    flexmock(
        packit.upstream.tarfile).should_receive("is_tarfile").and_return(False)
    ups.package_config.archive_root_dir_template = template

    archive = ups.create_archive()
    archive_root_dir = Archive(ups,
                               ups.get_version()).get_archive_root_dir(archive)

    assert archive_root_dir == expected_output
Exemple #3
0
def test_get_archive_root_dir_from_template(template, expected_return_value,
                                            upstream_mock):
    upstream_mock.package_config.archive_root_dir_template = template
    assert (Archive(
        upstream_mock,
        "1.0").get_archive_root_dir_from_template() == expected_return_value)
Exemple #4
0
def test_get_tar_archive_dir(archive_items, expected_result, upstream_mock,
                             tar_mock):
    tar_mock(archive_items=archive_items)
    assert (Archive(upstream_mock).get_archive_root_dir_from_tar("_archive") ==
            expected_result)