2018-03-13 13:29:13 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2018-03-29 14:34:52 +00:00
|
|
|
try:
|
|
|
|
import unittest2 as unittest
|
|
|
|
except ImportError:
|
|
|
|
import unittest
|
|
|
|
|
2018-03-13 13:29:13 +00:00
|
|
|
import mock
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
|
|
|
|
|
|
from pungi.phases.gather.sources.source_module import GatherSourceModule
|
|
|
|
from tests import helpers
|
2018-03-16 06:15:01 +00:00
|
|
|
from pungi import Modulemd
|
2018-03-13 13:29:13 +00:00
|
|
|
|
|
|
|
|
2018-03-16 06:15:01 +00:00
|
|
|
@unittest.skipUnless(Modulemd is not None, 'Skipped test, no module support.')
|
2018-03-13 13:29:13 +00:00
|
|
|
class TestGatherSourceModule(helpers.PungiTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(TestGatherSourceModule, self).setUp()
|
|
|
|
|
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
self.mmd = self.compose.variants["Server"].add_fake_module(
|
2018-05-02 13:36:52 +00:00
|
|
|
"testmodule:master:1:2017", rpm_nvrs=["pkg-0:1.0.0-1.x86_64", "pkg-0:1.0.0-1.i686"])
|
2018-03-13 13:29:13 +00:00
|
|
|
|
|
|
|
mock_rpm = mock.Mock(version='1.0.0', release='1',
|
|
|
|
epoch=0, excludearch=None, exclusivearch=None,
|
2018-05-02 13:36:52 +00:00
|
|
|
sourcerpm='pkg-1.0.0-1', nevra='pkg-0:1.0.0-1.x86_64',
|
2018-03-22 13:02:33 +00:00
|
|
|
arch="x86_64")
|
2018-03-13 13:29:13 +00:00
|
|
|
mock_rpm.name = 'pkg'
|
2018-10-01 13:38:14 +00:00
|
|
|
self.compose.variants['Server'].nsvc_to_pkgset["testmodule:master:1:2017"].rpms_by_arch['x86_64'] = [mock_rpm]
|
2018-03-22 13:02:33 +00:00
|
|
|
mock_rpm = mock.Mock(version='1.0.0', release='1',
|
|
|
|
epoch=0, excludearch=None, exclusivearch=None,
|
2018-05-02 13:36:52 +00:00
|
|
|
sourcerpm='pkg-1.0.0-1', nevra='pkg-0:1.0.0-1.i686',
|
2018-03-22 13:02:33 +00:00
|
|
|
arch="i686")
|
|
|
|
mock_rpm.name = 'pkg'
|
2018-10-01 13:38:14 +00:00
|
|
|
self.compose.variants['Server'].nsvc_to_pkgset["testmodule:master:1:2017"].rpms_by_arch['i686'] = [mock_rpm]
|
2018-03-13 13:29:13 +00:00
|
|
|
|
|
|
|
def test_gather_module(self):
|
|
|
|
source = GatherSourceModule(self.compose)
|
|
|
|
packages, groups = source("x86_64", self.compose.variants["Server"])
|
|
|
|
self.assertEqual(len(packages), 1)
|
2018-05-02 13:36:52 +00:00
|
|
|
self.assertEqual(list(packages)[0][0].nevra, "pkg-0:1.0.0-1.x86_64")
|
2018-03-22 13:02:33 +00:00
|
|
|
self.assertEqual(len(groups), 0)
|
|
|
|
|
|
|
|
variant = self.compose.variants["Server"]
|
2018-09-05 06:51:38 +00:00
|
|
|
arch_mmd = variant.arch_mmds["x86_64"]["testmodule:master:1:2017"]
|
2018-03-22 13:02:33 +00:00
|
|
|
self.assertEqual(set(arch_mmd.get_rpm_artifacts().get()),
|
2018-05-02 13:36:52 +00:00
|
|
|
set(["pkg-0:1.0.0-1.x86_64"]))
|
2018-03-22 13:02:33 +00:00
|
|
|
|
|
|
|
def test_gather_multilib(self):
|
|
|
|
multilib = Modulemd.SimpleSet()
|
|
|
|
multilib.add("x86_64")
|
|
|
|
self.mmd.get_rpm_components()["pkg"].set_multilib(multilib)
|
|
|
|
|
|
|
|
source = GatherSourceModule(self.compose)
|
|
|
|
packages, groups = source("x86_64", self.compose.variants["Server"])
|
|
|
|
self.assertEqual(len(packages), 2)
|
|
|
|
self.assertEqual(set(package[0].nevra for package in packages),
|
2018-05-02 13:36:52 +00:00
|
|
|
set(["pkg-0:1.0.0-1.x86_64", "pkg-0:1.0.0-1.i686"]))
|
2018-03-13 13:29:13 +00:00
|
|
|
self.assertEqual(len(groups), 0)
|
|
|
|
|
|
|
|
variant = self.compose.variants["Server"]
|
2018-09-05 06:51:38 +00:00
|
|
|
arch_mmd = variant.arch_mmds["x86_64"]["testmodule:master:1:2017"]
|
2018-03-15 12:31:58 +00:00
|
|
|
self.assertEqual(set(arch_mmd.get_rpm_artifacts().get()),
|
2018-05-02 13:36:52 +00:00
|
|
|
set(["pkg-0:1.0.0-1.x86_64", "pkg-0:1.0.0-1.i686"]))
|
2018-03-13 13:29:13 +00:00
|
|
|
|
|
|
|
def test_gather_filtered_module(self):
|
|
|
|
filter_set = Modulemd.SimpleSet()
|
|
|
|
filter_set.add("pkg")
|
|
|
|
self.mmd.set_rpm_filter(filter_set)
|
|
|
|
|
|
|
|
source = GatherSourceModule(self.compose)
|
|
|
|
packages, groups = source("x86_64", self.compose.variants["Server"])
|
|
|
|
self.assertEqual(len(packages), 0)
|
|
|
|
self.assertEqual(len(groups), 0)
|
|
|
|
|
|
|
|
variant = self.compose.variants["Server"]
|
2018-09-05 06:51:38 +00:00
|
|
|
arch_mmd = variant.arch_mmds["x86_64"]["testmodule:master:1:2017"]
|
2018-03-15 12:31:58 +00:00
|
|
|
self.assertEqual(len(arch_mmd.get_rpm_artifacts().get()), 0)
|