How to use pyp2rpm - 10 common examples

To help you get started, we’ve selected a few pyp2rpm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fedora-python / pyp2rpm / tests / test_package_getters.py View on Github external
from flexmock import flexmock

try:
    import xmlrpclib
except ImportError:
    import xmlrpc.client as xmlrpclib

from pyp2rpm.package_getters import LocalFileGetter, PypiDownloader, get_url
from pyp2rpm.exceptions import MissingUrlException, NoSuchPackageException
from pyp2rpm import settings

tests_dir = os.path.split(os.path.abspath(__file__))[0]


class TestPackageGetters(object):
    client = xmlrpclib.ServerProxy(settings.PYPI_URL)

    @pytest.mark.parametrize(('name', 'version', 'wheel', 'hf', 'expected_url', 'expected_md5'), [
        ('setuptools', '18.3.1', False, False,
         'https://files.pythonhosted.org/packages/source/s/setuptools/setuptools-18.3.1.tar.gz',
         '748187b93152fa60287dfb896837fd7c'),
        ('setuptools', '18.3.1', True, False,
         'https://files.pythonhosted.org/packages/source/s/setuptools/setuptools-18.3.1-py2.py3-none-any.whl',
         'a21a4d02d0bab2eac499cca72faeb076'),
        ('setuptools', '18.3.1', False, True,
         'https://files.pythonhosted.org/packages/86/8a/c4666b05c74e840eb9b09d28f4e7ae76fc9075e8c653d0eb4d265a5b49d9/setuptools-18.3.1.tar.gz',
         '748187b93152fa60287dfb896837fd7c'),
        ('pypandoc', '1.1.3', False, False,
         'https://files.pythonhosted.org/packages/source/p/pypandoc/pypandoc-1.1.3.zip',
         '771f376bf9c936a90159cd94235998c2'),
    ])
    @pytest.mark.webtest
github fedora-python / pyp2rpm / tests / test_metadata_extractors.py View on Github external
def setup_method(self, method):
        self.nc = NameConvertor('fedora')
        self.e = []
        for archive in ('plumbum-0.9.0.tar.gz',
                        'pytest-2.2.3.zip',
                        'simpleeval-0.8.7.tar.gz',
                        'coverage_pth-0.0.1.tar.gz'):
            name, version = archive.split('-')
            self.e.append(me.SetupPyMetadataExtractor('{0}{1}'.format(
                self.td_dir, archive), name, self.nc, version[:5]))
github fedora-python / pyp2rpm / tests / test_convertor.py View on Github external
from flexmock import flexmock

from pyp2rpm.convertor import Convertor
from pyp2rpm.exceptions import NoSuchPackageException
from pyp2rpm.metadata_extractors import (SetupPyMetadataExtractor,
                                         WheelMetadataExtractor)
from pyp2rpm.package_getters import PypiDownloader, LocalFileGetter
from pyp2rpm.package_data import PackageData

tests_dir = os.path.split(os.path.abspath(__file__))[0]


class TestConvertor(object):
    td_dir = '{0}/test_data/'.format(tests_dir)
    client = flexmock(package_releases=lambda n, hidden: n == 'spam' and ['0.1'] or [])
    Convertor._client = client  # flexmock can't mock properties yet

    @pytest.mark.parametrize(('sf', 'g'), [
        ('spam', PypiDownloader),
        ('{0}restsh-0.1.tar.gz'.format(td_dir), LocalFileGetter)
    ])
    def test_getter_good_data(self, sf, g):
        c = Convertor(package=sf)
        assert isinstance(c.getter, g)

    @pytest.mark.parametrize(('sf', 'expected'), [
        ('eggs', NoSuchPackageException),
        ('/spam/beans/eggs/ham', NoSuchPackageException)
    ])
    def test_getter_bad_data(self, sf, expected):
        with pytest.raises(expected):
            c = Convertor(package=sf)
github fedora-python / pyp2rpm / tests / test_name_convertor.py View on Github external
def setup_method(self, method):
        self.ncf = NameConvertor('fedora')
        self.ncm = NameConvertor('mageia')
github fedora-python / pyp2rpm / tests / test_metadata_extractors.py View on Github external
def setup_method(self, method):
        self.nc = NameConvertor('fedora')
        self.e = []
        for archive, name, version in [
                ('setuptools-19.6-py2.py3-none-any.whl',
                 'setuptools', '19.6.2'),
                ('py2exe-0.9.2.2-py33.py34-none-any.whl',
                 'py2exe', '0.9.2.2')]:
            self.e.append(me.WheelMetadataExtractor('{0}{1}'.format(
                self.td_dir, archive), name, self.nc, version, venv=False))
github fedora-python / pyp2rpm / tests / test_virtualenv.py View on Github external
def setup_method(self, method):
        self.temp_dir = tempfile.mkdtemp()
        self.venv = VirtualEnv(name=None, version=None,
                               temp_dir=self.temp_dir,
                               name_convertor=NameConvertor(DEFAULT_DISTRO),
                               base_python_version=DEFAULT_PYTHON_VERSION)
github fedora-python / pyp2rpm / tests / test_name_convertor.py View on Github external
def test_rpm_versioned_name(self, name, version, expected):
        assert NameConvertor.rpm_versioned_name(name, version) == expected
github fedora-python / pyp2rpm / tests / test_metadata_extractors.py View on Github external
def test_doc_files(self, doc_files, license, other):
        flexmock(me.SetupPyMetadataExtractor).should_receive(
            'doc_files').and_return(doc_files)
        data = self.e[0].extract_data()
        assert data.data['doc_license'] == license
        assert data.data['doc_files'] == other
github fedora-python / pyp2rpm / tests / test_metadata_extractors.py View on Github external
def test_init_extractor(self, b_version, what, expected):
        extractor = me.SetupPyMetadataExtractor(
            '{0}netjsonconfig-0.5.1.tar.gz'.format(self.td_dir),
            'netjsonconfig', self.nc, '0.5.1', base_python_version=b_version)
        if extractor.unsupported_version != b_version:
            assert extractor.metadata.get(what) == expected
github fedora-python / pyp2rpm / tests / test_metadata_extractors.py View on Github external
def setup_method(self, method):
        # create fresh extractors for every test

        self.nc = NameConvertor('fedora')
        self.e = [me.SetupPyMetadataExtractor('{0}plumbum-0.9.0.tar.gz'.format(
            self.td_dir), 'plumbum', self.nc, '0.9.0'),
            me.SetupPyMetadataExtractor(
            '{0}pytest-2.2.3.zip'.format(self.td_dir), 'pytest',
                self.nc, '2.2.3'),
            me.SetupPyMetadataExtractor(
            '{0}bitarray-0.8.0.tar.gz'.format(self.td_dir), 'bitarray',
                self.nc, '0.8.0'),
            me.SetupPyMetadataExtractor(
            '{0}versiontools-1.9.1.tar.gz'.format(self.td_dir),
                'versiontools', self.nc, '1.9.1'),
            me.SetupPyMetadataExtractor(
            '{0}isholiday-0.1.tar.gz'.format(self.td_dir),
                'isholiday', self.nc, '0.1'),
        ]