def test_apt_unmarshal_invalid_data(): test_dict = "not-a-dict" with pytest.raises(errors.PackageRepositoryValidationError) as raised: PackageRepositoryApt.unmarshal(test_dict) # type: ignore err = raised.value assert str( err) == "Invalid package repository for 'not-a-dict': invalid object." assert err.details == "Package repository must be a valid dictionary object." assert err.resolution == ( "Verify repository configuration and ensure that the correct syntax is used." )
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 raised: PackageRepositoryApt.unmarshal(test_dict) err = raised.value assert str(err) == ( "Invalid package repository for 'http://archive.ubuntu.com/ubuntu': " "unsupported type 'aptx'.") assert err.details == "The only currently supported type is 'apt'." assert err.resolution == ( "Verify repository configuration and ensure that 'type' is correctly specified." )
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 raised: PackageRepositoryApt.unmarshal(test_dict) err = raised.value assert str(err) == ( "Invalid package repository for 'http://archive.ubuntu.com/ubuntu': " "unsupported properties 'foo', 'foo2'.") assert err.details is None assert err.resolution == "Verify repository configuration and ensure it is correct."