mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-05-12 10:57:58 +08:00
Format the coding style across the codebase using "black" and manual tweaks
The main benefit of this commit is that the use of double quotes is now consistent.
This commit is contained in:
@@ -17,7 +17,6 @@ from tests import clean_database, make_module
|
||||
|
||||
|
||||
class TestMockModuleBuilder:
|
||||
|
||||
def setup_method(self, test_method):
|
||||
clean_database()
|
||||
self.resultdir = tempfile.mkdtemp()
|
||||
@@ -32,60 +31,63 @@ class TestMockModuleBuilder:
|
||||
"module_id": 2,
|
||||
"package": "ed",
|
||||
"format": "rpms",
|
||||
"scmurl": ("https://src.fedoraproject.org/rpms/ed"
|
||||
"?#01bf8330812fea798671925cc537f2f29b0bd216"),
|
||||
"scmurl": (
|
||||
"https://src.fedoraproject.org/rpms/ed"
|
||||
"?#01bf8330812fea798671925cc537f2f29b0bd216"
|
||||
),
|
||||
"batch": 2,
|
||||
"ref": "01bf8330812fea798671925cc537f2f29b0bd216"
|
||||
"ref": "01bf8330812fea798671925cc537f2f29b0bd216",
|
||||
},
|
||||
{
|
||||
"module_id": 2,
|
||||
"package": "mksh",
|
||||
"format": "rpms",
|
||||
"scmurl": ("https://src.fedoraproject.org/rpms/mksh"
|
||||
"?#f70fd11ddf96bce0e2c64309706c29156b39141d"),
|
||||
"scmurl": (
|
||||
"https://src.fedoraproject.org/rpms/mksh"
|
||||
"?#f70fd11ddf96bce0e2c64309706c29156b39141d"
|
||||
),
|
||||
"batch": 3,
|
||||
"ref": "f70fd11ddf96bce0e2c64309706c29156b39141d"
|
||||
"ref": "f70fd11ddf96bce0e2c64309706c29156b39141d",
|
||||
},
|
||||
]
|
||||
|
||||
base_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
mmd = Modulemd.Module().new_from_file(os.path.join(
|
||||
base_dir, '..', 'staged_data', 'testmodule-with-filters.yaml'))
|
||||
mmd = Modulemd.Module().new_from_file(
|
||||
os.path.join(base_dir, "..", "staged_data", "testmodule-with-filters.yaml"))
|
||||
mmd.upgrade()
|
||||
mmd.set_xmd(glib.dict_values({
|
||||
'mbs': {
|
||||
'rpms': {
|
||||
'ed': {'ref': '01bf8330812fea798671925cc537f2f29b0bd216'},
|
||||
'mksh': {'ref': 'f70fd11ddf96bce0e2c64309706c29156b39141d'}
|
||||
"mbs": {
|
||||
"rpms": {
|
||||
"ed": {"ref": "01bf8330812fea798671925cc537f2f29b0bd216"},
|
||||
"mksh": {"ref": "f70fd11ddf96bce0e2c64309706c29156b39141d"},
|
||||
},
|
||||
'buildrequires':
|
||||
{
|
||||
'host': {
|
||||
'version': '20171024133034',
|
||||
'filtered_rpms': [],
|
||||
'stream': 'master',
|
||||
'ref': '6df253bb3c53e84706c01b8ab2d5cac24f0b6d45',
|
||||
'context': '00000000'
|
||||
"buildrequires": {
|
||||
"host": {
|
||||
"version": "20171024133034",
|
||||
"filtered_rpms": [],
|
||||
"stream": "master",
|
||||
"ref": "6df253bb3c53e84706c01b8ab2d5cac24f0b6d45",
|
||||
"context": "00000000",
|
||||
},
|
||||
'platform': {
|
||||
'version': '20171028112959',
|
||||
'filtered_rpms': [],
|
||||
'stream': 'master',
|
||||
'ref': '4f7787370a931d57421f9f9555fc41c3e31ff1fa',
|
||||
'context': '00000000'
|
||||
"platform": {
|
||||
"version": "20171028112959",
|
||||
"filtered_rpms": [],
|
||||
"stream": "master",
|
||||
"ref": "4f7787370a931d57421f9f9555fc41c3e31ff1fa",
|
||||
"context": "00000000",
|
||||
},
|
||||
},
|
||||
"scmurl": "file:///testdir",
|
||||
"commit": "5566bc792ec7a03bb0e28edd1b104a96ba342bd8",
|
||||
"requires": {
|
||||
"platform": {
|
||||
"version": "20171028112959",
|
||||
"filtered_rpms": [],
|
||||
"stream": "master",
|
||||
"ref": "4f7787370a931d57421f9f9555fc41c3e31ff1fa",
|
||||
"context": "00000000",
|
||||
}
|
||||
},
|
||||
'scmurl': 'file:///testdir',
|
||||
'commit': '5566bc792ec7a03bb0e28edd1b104a96ba342bd8',
|
||||
'requires': {
|
||||
'platform': {
|
||||
'version': '20171028112959',
|
||||
'filtered_rpms': [],
|
||||
'stream': 'master',
|
||||
'ref': '4f7787370a931d57421f9f9555fc41c3e31ff1fa',
|
||||
'context': '00000000'
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
module = ModuleBuild.create(
|
||||
@@ -113,37 +115,39 @@ class TestMockModuleBuilder:
|
||||
@mock.patch("module_build_service.conf.system", new="mock")
|
||||
def test_createrepo_filter_last_batch(self, *args):
|
||||
with make_session(conf) as session:
|
||||
module = self._create_module_with_filters(session, 3, koji.BUILD_STATES['COMPLETE'])
|
||||
module = self._create_module_with_filters(session, 3, koji.BUILD_STATES["COMPLETE"])
|
||||
|
||||
builder = MockModuleBuilder("mcurlej", module, conf, module.koji_tag,
|
||||
module.component_builds)
|
||||
builder = MockModuleBuilder(
|
||||
"mcurlej", module, conf, module.koji_tag, module.component_builds
|
||||
)
|
||||
builder.resultsdir = self.resultdir
|
||||
rpms = [
|
||||
"ed-1.14.1-4.module+24957a32.x86_64.rpm",
|
||||
"mksh-56b-1.module+24957a32.x86_64.rpm",
|
||||
"module-build-macros-0.1-1.module+24957a32.noarch.rpm"
|
||||
"module-build-macros-0.1-1.module+24957a32.noarch.rpm",
|
||||
]
|
||||
rpm_qf_output = dedent("""\
|
||||
ed 0 1.14.1 4.module+24957a32 x86_64
|
||||
mksh 0 56b-1 module+24957a32 x86_64
|
||||
module-build-macros 0 0.1 1.module+24957a32 noarch
|
||||
""")
|
||||
""")
|
||||
with mock.patch("os.listdir", return_value=rpms):
|
||||
with mock.patch("subprocess.check_output", return_value=rpm_qf_output):
|
||||
builder._createrepo()
|
||||
|
||||
with open(os.path.join(self.resultdir, "pkglist"), "r") as fd:
|
||||
pkglist = fd.read().strip()
|
||||
rpm_names = [kobo.rpmlib.parse_nvr(rpm)["name"] for rpm in pkglist.split('\n')]
|
||||
rpm_names = [kobo.rpmlib.parse_nvr(rpm)["name"] for rpm in pkglist.split("\n")]
|
||||
assert "ed" not in rpm_names
|
||||
|
||||
@mock.patch("module_build_service.conf.system", new="mock")
|
||||
def test_createrepo_not_last_batch(self):
|
||||
with make_session(conf) as session:
|
||||
module = self._create_module_with_filters(session, 2, koji.BUILD_STATES['COMPLETE'])
|
||||
module = self._create_module_with_filters(session, 2, koji.BUILD_STATES["COMPLETE"])
|
||||
|
||||
builder = MockModuleBuilder("mcurlej", module, conf, module.koji_tag,
|
||||
module.component_builds)
|
||||
builder = MockModuleBuilder(
|
||||
"mcurlej", module, conf, module.koji_tag, module.component_builds
|
||||
)
|
||||
builder.resultsdir = self.resultdir
|
||||
rpms = [
|
||||
"ed-1.14.1-4.module+24957a32.x86_64.rpm",
|
||||
@@ -152,23 +156,23 @@ class TestMockModuleBuilder:
|
||||
rpm_qf_output = dedent("""\
|
||||
ed 0 1.14.1 4.module+24957a32 x86_64
|
||||
mksh 0 56b-1 module+24957a32 x86_64
|
||||
""")
|
||||
""")
|
||||
with mock.patch("os.listdir", return_value=rpms):
|
||||
with mock.patch("subprocess.check_output", return_value=rpm_qf_output):
|
||||
builder._createrepo()
|
||||
|
||||
with open(os.path.join(self.resultdir, "pkglist"), "r") as fd:
|
||||
pkglist = fd.read().strip()
|
||||
rpm_names = [kobo.rpmlib.parse_nvr(rpm)["name"] for rpm in pkglist.split('\n')]
|
||||
rpm_names = [kobo.rpmlib.parse_nvr(rpm)["name"] for rpm in pkglist.split("\n")]
|
||||
assert "ed" in rpm_names
|
||||
|
||||
@mock.patch("module_build_service.conf.system", new="mock")
|
||||
def test_createrepo_empty_rmp_list(self, *args):
|
||||
with make_session(conf) as session:
|
||||
module = self._create_module_with_filters(session, 3, koji.BUILD_STATES['COMPLETE'])
|
||||
module = self._create_module_with_filters(session, 3, koji.BUILD_STATES["COMPLETE"])
|
||||
|
||||
builder = MockModuleBuilder("mcurlej", module, conf, module.koji_tag,
|
||||
module.component_builds)
|
||||
builder = MockModuleBuilder(
|
||||
"mcurlej", module, conf, module.koji_tag, module.component_builds)
|
||||
builder.resultsdir = self.resultdir
|
||||
rpms = []
|
||||
with mock.patch("os.listdir", return_value=rpms):
|
||||
@@ -180,7 +184,6 @@ class TestMockModuleBuilder:
|
||||
|
||||
|
||||
class TestMockModuleBuilderAddRepos:
|
||||
|
||||
def setup_method(self, test_method):
|
||||
clean_database(add_platform_module=False)
|
||||
import_fake_base_module("platform:f29:1:000000")
|
||||
@@ -190,27 +193,32 @@ class TestMockModuleBuilderAddRepos:
|
||||
|
||||
@mock.patch("module_build_service.conf.system", new="mock")
|
||||
@mock.patch(
|
||||
'module_build_service.config.Config.base_module_repofiles',
|
||||
"module_build_service.config.Config.base_module_repofiles",
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value=["/etc/yum.repos.d/bar.repo", "/etc/yum.repos.d/bar-updates.repo"],
|
||||
create=True)
|
||||
create=True,
|
||||
)
|
||||
@mock.patch("module_build_service.builder.MockModuleBuilder.open", create=True)
|
||||
@mock.patch(
|
||||
"module_build_service.builder.MockModuleBuilder.MockModuleBuilder._load_mock_config")
|
||||
"module_build_service.builder.MockModuleBuilder.MockModuleBuilder._load_mock_config"
|
||||
)
|
||||
@mock.patch(
|
||||
"module_build_service.builder.MockModuleBuilder.MockModuleBuilder._write_mock_config")
|
||||
def test_buildroot_add_repos(self, write_config, load_config, patched_open,
|
||||
base_module_repofiles):
|
||||
"module_build_service.builder.MockModuleBuilder.MockModuleBuilder._write_mock_config"
|
||||
)
|
||||
def test_buildroot_add_repos(
|
||||
self, write_config, load_config, patched_open, base_module_repofiles
|
||||
):
|
||||
patched_open.side_effect = [
|
||||
mock.mock_open(read_data="[fake]\nrepofile 1\n").return_value,
|
||||
mock.mock_open(read_data="[fake]\nrepofile 2\n").return_value,
|
||||
mock.mock_open(read_data="[fake]\nrepofile 3\n").return_value]
|
||||
mock.mock_open(read_data="[fake]\nrepofile 3\n").return_value,
|
||||
]
|
||||
|
||||
builder = MockModuleBuilder("user", self.app, conf, "module-app", [])
|
||||
|
||||
dependencies = {
|
||||
"repofile://": [self.platform.mmd()],
|
||||
"repofile:///etc/yum.repos.d/foo.repo": [self.foo.mmd(), self.app.mmd()]
|
||||
"repofile:///etc/yum.repos.d/foo.repo": [self.foo.mmd(), self.app.mmd()],
|
||||
}
|
||||
|
||||
builder.buildroot_add_repos(dependencies)
|
||||
|
||||
Reference in New Issue
Block a user