def test_valid_apt_ppa(self): repo = PackageRepositoryAptPpa(ppa="test/ppa") self.assertThat(repo.marshal(), Equals({ "type": "apt", "ppa": "test/ppa" }))
def test_ppa_unmarshal_invalid_apt_ppa_extra_keys(): test_dict = {"type": "apt", "ppa": "test/ppa", "test": "foo"} with pytest.raises(errors.PackageRepositoryValidationError) as exc_info: PackageRepositoryAptPpa.unmarshal(test_dict) assert (exc_info.value.brief == "Found unsupported package repository properties 'test'.") assert exc_info.value.details is None assert (exc_info.value.resolution == "Verify repository configuration and ensure that it is correct.")
def test_ppa_unmarshal_invalid_apt_ppa_type(): test_dict = {"type": "aptx", "ppa": "test/ppa"} with pytest.raises(errors.PackageRepositoryValidationError) as exc_info: PackageRepositoryAptPpa.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." )
def test_ppa_unmarshal_invalid_data(): test_dict = "not-a-dict" with pytest.raises(errors.PackageRepositoryValidationError) as exc_info: PackageRepositoryAptPpa.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." )
def test_install_ppa_invalid(apt_sources_mgr): repo = PackageRepositoryAptPpa(ppa="ppa-missing-slash") with pytest.raises(errors.AptPPAInstallError) as exc_info: apt_sources_mgr.install_package_repository_sources(package_repo=repo) assert exc_info.value._ppa == "ppa-missing-slash"
def test_ppa_invalid_ppa(): with pytest.raises(errors.PackageRepositoryValidationError) as exc_info: PackageRepositoryAptPpa(ppa="") assert exc_info.value.brief == "Invalid PPA ''." assert exc_info.value.details == "PPAs must be non-empty strings." assert ( exc_info.value.resolution == "Verify repository configuration and ensure that 'ppa' is correctly specified." )
def test_install_package_repository_key_ppa_from_keyserver( mock_install_key_from_keyserver, mock_is_key_installed, apt_gpg, ): package_repo = PackageRepositoryAptPpa(ppa="test/ppa", ) updated = apt_gpg.install_package_repository_key(package_repo=package_repo) assert updated is True assert mock_install_key_from_keyserver.mock_calls == [ call(key_id="FAKE-PPA-SIGNING-KEY", key_server="keyserver.ubuntu.com") ]
def test_ppa_marshal(): repo = PackageRepositoryAptPpa(ppa="test/ppa") assert repo.marshal() == {"type": "apt", "ppa": "test/ppa"}
( PackageRepositoryApt( key_id="A" * 40, name="IMPLIED-PATH", url="http://test.url/ubuntu", ), "snapcraft-IMPLIED-PATH.sources", dedent("""\ Types: deb URIs: http://test.url/ubuntu Suites: / Architectures: FAKE-HOST-ARCH """).encode(), ), ( PackageRepositoryAptPpa(ppa="test/ppa"), "snapcraft-ppa-test_ppa.sources", dedent("""\ Types: deb URIs: http://ppa.launchpad.net/test/ppa/ubuntu Suites: FAKE-CODENAME Components: main Architectures: FAKE-HOST-ARCH """).encode(), ), ], ) def test_install(package_repo, name, content, apt_sources_mgr, mock_sudo_write): sources_path = apt_sources_mgr._sources_list_d / name
def test_ppa_install(mock_repo): repo = PackageRepositoryAptPpa(ppa="test/ppa") repo.install() assert mock_repo.mock_calls == [mock.call.install_ppa(ppa="test/ppa")]