Ejemplo n.º 1
0
def test_apt_unmarshal_invalid_extra_keys():
    test_dict = {
        "architectures": ["amd64", "i386"],
        "components": ["main", "multiverse"],
        "formats": ["deb", "deb-src"],
        "key-id": "A" * 40,
        "key-server": "keyserver.ubuntu.com",
        "name": "test-name",
        "suites": ["xenial", "xenial-updates"],
        "type": "apt",
        "url": "http://archive.ubuntu.com/ubuntu",
        "foo": "bar",
        "foo2": "bar",
    }

    with pytest.raises(errors.PackageRepositoryValidationError) as exc_info:
        PackageRepositoryApt.unmarshal(test_dict)

    assert (
        exc_info.value.brief
        == "Found unsupported package repository properties 'foo', 'foo2'."
    )
    assert exc_info.value.details is None
    assert (
        exc_info.value.resolution
        == "Verify repository configuration and ensure it is correct."
    )
Ejemplo n.º 2
0
def test_apt_unmarshal_invalid_data():
    test_dict = "not-a-dict"

    with pytest.raises(errors.PackageRepositoryValidationError) as exc_info:
        PackageRepositoryApt.unmarshal(test_dict)

    assert exc_info.value.brief == "Invalid package repository object 'not-a-dict'."
    assert (
        exc_info.value.details
        == "Package repository must be a valid dictionary object."
    )
    assert (
        exc_info.value.resolution
        == "Verify repository configuration and ensure that the correct syntax is used."
    )
Ejemplo n.º 3
0
def test_apt_unmarshal_invalid_type():
    test_dict = {
        "architectures": ["amd64", "i386"],
        "components": ["main", "multiverse"],
        "formats": ["deb", "deb-src"],
        "key-id": "A" * 40,
        "key-server": "keyserver.ubuntu.com",
        "name": "test-name",
        "suites": ["xenial", "xenial-updates"],
        "type": "aptx",
        "url": "http://archive.ubuntu.com/ubuntu",
    }

    with pytest.raises(errors.PackageRepositoryValidationError) as exc_info:
        PackageRepositoryApt.unmarshal(test_dict)

    assert exc_info.value.brief == "Unsupported type 'aptx'."
    assert exc_info.value.details == "The only currently supported type is 'apt'."
    assert (
        exc_info.value.resolution
        == "Verify repository configuration and ensure that 'type' is correctly specified."
    )