How to use the pyp2rpm.convertor.Convertor function in pyp2rpm

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_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_convertor.py View on Github external
def test_getter_bad_data(self, sf, expected):
        with pytest.raises(expected):
            c = Convertor(package=sf)
            c.getter
github fedora-python / pyp2rpm / tests / test_convertor.py View on Github external
def test_get_metadata_extractor(self, sf, expected):
        c = Convertor(package=sf)
        c.local_file = sf
        c.name = 'plumbum'
        assert isinstance(c.metadata_extractor, expected)
github fedora-python / pyp2rpm / tests / test_convertor.py View on Github external
def test_bad_versions(self, self_bv, self_pv):
        c = Convertor(package='pkg', base_python_version=self_bv,
                      python_versions=self_pv, template='epel6.spec',
                      distro='epel6')
        data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1')
        with pytest.raises(SystemExit):
            c.merge_versions(data)
github fedora-python / pyp2rpm / tests / test_convertor.py View on Github external
def test_getter_good_data(self, sf, g):
        c = Convertor(package=sf)
        assert isinstance(c.getter, g)
github fedora-python / pyp2rpm / tests / test_convertor.py View on Github external
def test_merge_versions_epel7(self, self_bv, self_pv, data_pv,
                                  expected_bv, expected_pv):
        c = Convertor(package='pkg', base_python_version=self_bv,
                      python_versions=self_pv, template='epel7.spec',
                      distro='epel7')
        data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1')
        data.python_versions = data_pv
        c.merge_versions(data)
        assert data.base_python_version == expected_bv
        assert data.python_versions == expected_pv
github fedora-python / pyp2rpm / tests / test_convertor.py View on Github external
def test_merge_versions_fedora(self, self_bv, self_pv, data_pv,
                                   expected_bv, expected_pv):
        c = Convertor(package='pkg', base_python_version=self_bv,
                      python_versions=self_pv, template='fedora.spec')
        data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1')
        data.python_versions = data_pv
        c.merge_versions(data)
        assert data.base_python_version == expected_bv
        assert data.python_versions == expected_pv
github fedora-python / pyp2rpm / tests / test_convertor.py View on Github external
def test_merge_versions_epel6(self, self_bv, self_pv, data_bv, data_pv,
                                  expected_bv, expected_pv):
        c = Convertor(package='pkg', base_python_version=self_bv,
                      python_versions=self_pv, template='epel6.spec',
                      distro='epel6')
        data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1')
        data.base_python_version = data_bv
        data.python_versions = data_pv
        c.merge_versions(data)
        assert data.base_python_version == expected_bv
        assert data.python_versions == expected_pv
github fedora-python / pyp2rpm / pyp2rpm / bin.py View on Github external
if srpm or s:
        register_console_log_handler()

    distro = o
    if t and os.path.splitext(t)[0] in settings.KNOWN_DISTROS:
        distro = t
    if not distro and not (b or p):
        raise click.UsageError("Default python versions for template {0} are "
                               "missing in settings, add them or use flags "
                               "-b/-p to set python versions.".format(t))

    logger = logging.getLogger(__name__)

    logger.info('Pyp2rpm initialized.')

    convertor = Convertor(package=package,
                          version=v,
                          prerelease=prerelease,
                          save_dir=d,
                          template=t or settings.DEFAULT_TEMPLATE,
                          distro=distro,
                          base_python_version=b,
                          python_versions=p,
                          rpm_name=r,
                          proxy=proxy,
                          venv=venv,
                          autonc=autonc)

    logger.debug(
        'Convertor: {0} created. Trying to convert.'.format(convertor))
    converted = convertor.convert()
    logger.debug('Convertor: {0} succesfully converted.'.format(convertor))