Esempio n. 1
0
    def test_with_context_without_build(self):
        module = 'eog:my-stream:20180821163756:775baa8e'
        module_koji_nvr = 'eog-my_stream-20180821163756.775baa8e'
        koji_return = None

        spec = ModuleSpec.from_str(module)
        session = flexmock()
        (session.should_receive('getBuild').with_args(
            module_koji_nvr).and_return(koji_return))

        with pytest.raises(Exception) as e:
            get_koji_module_build(session, spec)
        assert 'No build found' in str(e.value)
    def _resolve_modules(self, modules):
        koji_session = get_koji_session(self.workflow, fallback=NO_FALLBACK)

        resolved_modules = {}
        for module_spec in modules:
            build, rpm_list = get_koji_module_build(koji_session, module_spec)

            # The returned RPM list contains source RPMs and RPMs for all
            # architectures.
            rpms = [
                '{name}-{epochnum}:{version}-{release}.{arch}.rpm'.format(
                    epochnum=rpm['epoch'] or 0, **rpm) for rpm in rpm_list
            ]

            # strict=False - don't break if new fields are added
            mmd = Modulemd.ModuleStream.read_string(
                build['extra']['typeinfo']['module']['modulemd_str'],
                strict=False)
            # Make sure we have a version 2 modulemd file
            mmd = mmd.upgrade(Modulemd.ModuleStreamVersionEnum.TWO)

            resolved_modules[module_spec.name] = ModuleInfo(
                module_spec.name, module_spec.stream, module_spec.version, mmd,
                rpms)
        return resolved_modules
Esempio n. 3
0
    def test_without_context(self, koji_return, should_raise):
        module = 'eog:master:20180821163756'
        spec = ModuleSpec.from_str(module)

        session = flexmock()
        (session.should_receive('getPackageID').with_args('eog').and_return(
            303))
        (session.should_receive('listBuilds').with_args(
            packageID=303, type='module',
            state=koji.BUILD_STATES['COMPLETE']).and_return(koji_return))

        if should_raise:
            with pytest.raises(Exception) as e:
                get_koji_module_build(session, spec)
            assert should_raise in str(e.value)
        else:
            self.mock_get_rpms(session)
            get_koji_module_build(session, spec)
Esempio n. 4
0
    def test_with_context(self):
        module = 'eog:my-stream:20180821163756:775baa8e'
        module_koji_nvr = 'eog-my_stream-20180821163756.775baa8e'
        koji_return = {
            'build_id': 1138198,
            'name': 'eog',
            'version': 'my_stream',
            'release': '20180821163756.775baa8e',
            'extra': {
                'typeinfo': {
                    'module': {
                        'modulemd_str': 'document: modulemd\nversion: 2'
                    }
                }
            }
        }

        spec = ModuleSpec.from_str(module)
        session = flexmock()
        (session.should_receive('getBuild').with_args(
            module_koji_nvr).and_return(koji_return))
        self.mock_get_rpms(session)

        get_koji_module_build(session, spec)