def test_package_safe_name_is_correct(pkg_name, expected_name): package = package_file.PackageFile( filename="tests/fixtures/deprecated-pypirc", comment=None, metadata=pretend.stub(name=pkg_name), python_version=None, filetype=None, ) assert package.safe_name == expected_name
def test_package_signed_name_is_correct(): filename = 'tests/fixtures/deprecated-pypirc' pkg = package.PackageFile(filename=filename, comment=None, metadata=pretend.stub(name="deprecated-pypirc"), python_version=None, filetype=None) assert pkg.signed_basefilename == "deprecated-pypirc.asc" assert pkg.signed_filename == (filename + '.asc')
def test_sign_file_with_identity(monkeypatch): replaced_check_call = pretend.call_recorder(lambda args: None) monkeypatch.setattr(package.subprocess, 'check_call', replaced_check_call) filename = 'tests/fixtures/deprecated-pypirc' pkg = package.PackageFile(filename=filename, comment=None, metadata=pretend.stub(name="deprecated-pypirc"), python_version=None, filetype=None) try: pkg.sign('gpg', 'identity') except IOError: pass args = ('gpg', '--detach-sign', '--local-user', 'identity', '-a', filename) assert replaced_check_call.calls == [pretend.call(args)]
def test_sign_file_with_identity(monkeypatch): replaced_check_call = pretend.call_recorder(lambda args: None) monkeypatch.setattr(package_file.subprocess, "check_call", replaced_check_call) filename = "tests/fixtures/deprecated-pypirc" package = package_file.PackageFile( filename=filename, comment=None, metadata=pretend.stub(name="deprecated-pypirc"), python_version=None, filetype=None, ) try: package.sign("gpg", "identity") except IOError: pass args = ("gpg", "--detach-sign", "--local-user", "identity", "-a", filename) assert replaced_check_call.calls == [pretend.call(args)]
def test_metadata_dictionary(gpg_signature): meta = pretend.stub( name="whatever", version=pretend.stub(), metadata_version=pretend.stub(), summary=pretend.stub(), home_page=pretend.stub(), author=pretend.stub(), author_email=pretend.stub(), maintainer=pretend.stub(), maintainer_email=pretend.stub(), license=pretend.stub(), description=pretend.stub(), keywords=pretend.stub(), platforms=pretend.stub(), classifiers=pretend.stub(), download_url=pretend.stub(), supported_platforms=pretend.stub(), provides=pretend.stub(), requires=pretend.stub(), obsoletes=pretend.stub(), project_urls=pretend.stub(), provides_dist=pretend.stub(), obsoletes_dist=pretend.stub(), requires_dist=pretend.stub(), requires_external=pretend.stub(), requires_python=pretend.stub(), provides_extras=pretend.stub(), description_content_type=pretend.stub(), ) package = package_file.PackageFile( filename="tests/fixtures/twine-1.5.0-py2.py3-none-any.whl", comment=pretend.stub(), metadata=meta, python_version=pretend.stub(), filetype=pretend.stub(), ) package.gpg_signature = gpg_signature result = package.metadata_dictionary() # identify release assert result["name"] == package.safe_name assert result["version"] == meta.version # file content assert result["filetype"] == package.filetype assert result["pyversion"] == package.python_version # additional meta-data assert result["metadata_version"] == meta.metadata_version assert result["summary"] == meta.summary assert result["home_page"] == meta.home_page assert result["author"] == meta.author assert result["author_email"] == meta.author_email assert result["maintainer"] == meta.maintainer assert result["maintainer_email"] == meta.maintainer_email assert result["license"] == meta.license assert result["description"] == meta.description assert result["keywords"] == meta.keywords assert result["platform"] == meta.platforms assert result["classifiers"] == meta.classifiers assert result["download_url"] == meta.download_url assert result["supported_platform"] == meta.supported_platforms assert result["comment"] == package.comment # PEP 314 assert result["provides"] == meta.provides assert result["requires"] == meta.requires assert result["obsoletes"] == meta.obsoletes # Metadata 1.2 assert result["project_urls"] == meta.project_urls assert result["provides_dist"] == meta.provides_dist assert result["obsoletes_dist"] == meta.obsoletes_dist assert result["requires_dist"] == meta.requires_dist assert result["requires_external"] == meta.requires_external assert result["requires_python"] == meta.requires_python # Metadata 2.1 assert result["provides_extras"] == meta.provides_extras assert result["description_content_type"] == meta.description_content_type # GPG signature assert result.get("gpg_signature") == gpg_signature
def test_metadata_dictionary(gpg_signature): meta = pretend.stub( name='whatever', version=pretend.stub(), metadata_version=pretend.stub(), summary=pretend.stub(), home_page=pretend.stub(), author=pretend.stub(), author_email=pretend.stub(), maintainer=pretend.stub(), maintainer_email=pretend.stub(), license=pretend.stub(), description=pretend.stub(), keywords=pretend.stub(), platforms=pretend.stub(), classifiers=pretend.stub(), download_url=pretend.stub(), supported_platforms=pretend.stub(), provides=pretend.stub(), requires=pretend.stub(), obsoletes=pretend.stub(), project_urls=pretend.stub(), provides_dist=pretend.stub(), obsoletes_dist=pretend.stub(), requires_dist=pretend.stub(), requires_external=pretend.stub(), requires_python=pretend.stub(), provides_extras=pretend.stub(), description_content_type=pretend.stub(), ) pkg = package.PackageFile( filename='tests/fixtures/twine-1.5.0-py2.py3-none-any.whl', comment=pretend.stub(), metadata=meta, python_version=pretend.stub(), filetype=pretend.stub(), ) pkg.gpg_signature = gpg_signature result = pkg.metadata_dictionary() # identify release assert result['name'] == pkg.safe_name assert result['version'] == meta.version # file content assert result['filetype'] == pkg.filetype assert result['pyversion'] == pkg.python_version # additional meta-data assert result['metadata_version'] == meta.metadata_version assert result['summary'] == meta.summary assert result['home_page'] == meta.home_page assert result['author'] == meta.author assert result['author_email'] == meta.author_email assert result['maintainer'] == meta.maintainer assert result['maintainer_email'] == meta.maintainer_email assert result['license'] == meta.license assert result['description'] == meta.description assert result['keywords'] == meta.keywords assert result['platform'] == meta.platforms assert result['classifiers'] == meta.classifiers assert result['download_url'] == meta.download_url assert result['supported_platform'] == meta.supported_platforms assert result['comment'] == pkg.comment # PEP 314 assert result['provides'] == meta.provides assert result['requires'] == meta.requires assert result['obsoletes'] == meta.obsoletes # Metadata 1.2 assert result['project_urls'] == meta.project_urls assert result['provides_dist'] == meta.provides_dist assert result['obsoletes_dist'] == meta.obsoletes_dist assert result['requires_dist'] == meta.requires_dist assert result['requires_external'] == meta.requires_external assert result['requires_python'] == meta.requires_python # Metadata 2.1 assert result['provides_extras'] == meta.provides_extras assert result['description_content_type'] == meta.description_content_type # GPG signature assert result.get('gpg_signature') == gpg_signature