mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-01 18:01:40 +08:00
pep8: don't surround '=' with spaces for keyword args
This commit is contained in:
@@ -171,7 +171,7 @@ mdpolicy=group:primary
|
||||
execute_cmd(['/usr/bin/createrepo_c', path])
|
||||
execute_cmd(['/usr/bin/modifyrepo_c', '--mdtype=modules', mmd_path, repodata_path])
|
||||
|
||||
def _add_repo(self, name, baseurl, extra = ""):
|
||||
def _add_repo(self, name, baseurl, extra=""):
|
||||
"""
|
||||
Adds repository to Mock config file. Call _write_mock_config() to
|
||||
actually write the config file to filesystem.
|
||||
|
||||
@@ -13,7 +13,7 @@ logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
|
||||
def build_from_scm(artifact_name, source, config, build_srpm,
|
||||
data = None, stdout=None, stderr=None):
|
||||
data=None, stdout=None, stderr=None):
|
||||
"""
|
||||
Builds the artifact from the SCM based source.
|
||||
|
||||
@@ -65,7 +65,7 @@ def build_from_scm(artifact_name, source, config, build_srpm,
|
||||
return ret
|
||||
|
||||
|
||||
def execute_cmd(args, stdout = None, stderr = None, cwd = None):
|
||||
def execute_cmd(args, stdout=None, stderr=None, cwd=None):
|
||||
"""
|
||||
Executes command defined by `args`. If `stdout` or `stderr` is set to
|
||||
Python file object, the stderr/stdout output is redirecter to that file.
|
||||
|
||||
@@ -73,11 +73,11 @@ def init_logging(conf):
|
||||
log_backend = conf.log_backend
|
||||
|
||||
if not log_backend or len(log_backend) == 0 or log_backend == "console":
|
||||
logging.basicConfig(level = conf.log_level, format = log_format)
|
||||
logging.basicConfig(level=conf.log_level, format=log_format)
|
||||
log = logging.getLogger()
|
||||
log.setLevel(conf.log_level)
|
||||
elif log_backend == "journal":
|
||||
logging.basicConfig(level = conf.log_level, format = log_format)
|
||||
logging.basicConfig(level=conf.log_level, format=log_format)
|
||||
try:
|
||||
from systemd import journal
|
||||
except:
|
||||
@@ -87,6 +87,6 @@ def init_logging(conf):
|
||||
log.propagate = False
|
||||
log.addHandler(journal.JournalHandler())
|
||||
else:
|
||||
logging.basicConfig(filename = conf.log_file, level = conf.log_level,
|
||||
format = log_format)
|
||||
logging.basicConfig(filename=conf.log_file, level=conf.log_level,
|
||||
format=log_format)
|
||||
log = logging.getLogger()
|
||||
|
||||
@@ -47,7 +47,7 @@ class SCM(object):
|
||||
# Assuming git for HTTP schemas
|
||||
types = module_build_service.utils.scm_url_schemes()
|
||||
|
||||
def __init__(self, url, branch = None, allowed_scm=None, allow_local = False):
|
||||
def __init__(self, url, branch=None, allowed_scm=None, allow_local=False):
|
||||
"""Initialize the SCM object using the specified scmurl.
|
||||
|
||||
If url is not in the list of allowed_scm, an error will be raised.
|
||||
@@ -124,7 +124,7 @@ class SCM(object):
|
||||
|
||||
@staticmethod
|
||||
@module_build_service.utils.retry(wait_on=RuntimeError)
|
||||
def _run(cmd, chdir=None, log_stdout = False):
|
||||
def _run(cmd, chdir=None, log_stdout=False):
|
||||
proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE, cwd=chdir)
|
||||
stdout, stderr = proc.communicate()
|
||||
if log_stdout and stdout:
|
||||
|
||||
@@ -613,8 +613,8 @@ def merge_included_mmd(mmd, included_mmd):
|
||||
else:
|
||||
mmd.xmd['mbs']['rpms'].update(included_mmd.xmd['mbs']['rpms'])
|
||||
|
||||
def record_component_builds(mmd, module, initial_batch = 1,
|
||||
previous_buildorder = None, main_mmd = None):
|
||||
def record_component_builds(mmd, module, initial_batch=1,
|
||||
previous_buildorder=None, main_mmd=None):
|
||||
import koji # Placed here to avoid py2/py3 conflicts...
|
||||
|
||||
# Format the modulemd by putting in defaults and replacing streams that
|
||||
|
||||
@@ -183,7 +183,7 @@ def init_data():
|
||||
session.commit()
|
||||
|
||||
|
||||
def scheduler_init_data(communicator_state = None):
|
||||
def scheduler_init_data(communicator_state=None):
|
||||
db.session.remove()
|
||||
db.drop_all()
|
||||
db.create_all()
|
||||
|
||||
@@ -72,7 +72,7 @@ class MockedSCM(object):
|
||||
|
||||
return scm_dir
|
||||
|
||||
def get_latest(self, branch = 'master'):
|
||||
def get_latest(self, branch='master'):
|
||||
return branch
|
||||
|
||||
class TestModuleBuilder(GenericBuilder):
|
||||
@@ -205,7 +205,7 @@ class TestModuleBuilder(GenericBuilder):
|
||||
|
||||
|
||||
@patch("module_build_service.config.Config.system",
|
||||
new_callable=PropertyMock, return_value = "test")
|
||||
new_callable=PropertyMock, return_value="test")
|
||||
@patch("module_build_service.builder.GenericBuilder.default_buildroot_groups",
|
||||
return_value={
|
||||
'srpm-build':
|
||||
@@ -316,13 +316,13 @@ class TestBuild(unittest.TestCase):
|
||||
return json.loads(rv.data)
|
||||
|
||||
with patch("module_build_service.config.Config.yaml_submit_allowed",
|
||||
new_callable=PropertyMock, return_value = True):
|
||||
new_callable=PropertyMock, return_value=True):
|
||||
conf.set_item("yaml_submit_allowed", True)
|
||||
data = submit()
|
||||
self.assertEqual(data['id'], 1)
|
||||
|
||||
with patch("module_build_service.config.Config.yaml_submit_allowed",
|
||||
new_callable=PropertyMock, return_value = False):
|
||||
new_callable=PropertyMock, return_value=False):
|
||||
data = submit()
|
||||
self.assertEqual(data['status'], 403)
|
||||
self.assertEqual(data['message'], 'YAML submission is not enabled')
|
||||
@@ -432,7 +432,7 @@ class TestBuild(unittest.TestCase):
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
@patch("module_build_service.config.Config.num_consecutive_builds",
|
||||
new_callable=PropertyMock, return_value = 1)
|
||||
new_callable=PropertyMock, return_value=1)
|
||||
def test_submit_build_concurrent_threshold(self, conf_num_consecutive_builds,
|
||||
mocked_scm, mocked_get_user,
|
||||
conf_system, dbg):
|
||||
@@ -476,7 +476,7 @@ class TestBuild(unittest.TestCase):
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
@patch("module_build_service.config.Config.num_consecutive_builds",
|
||||
new_callable=PropertyMock, return_value = 2)
|
||||
new_callable=PropertyMock, return_value=2)
|
||||
def test_try_to_reach_concurrent_threshold(self, conf_num_consecutive_builds,
|
||||
mocked_scm, mocked_get_user,
|
||||
conf_system, dbg):
|
||||
@@ -531,7 +531,7 @@ class TestBuild(unittest.TestCase):
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
@patch("module_build_service.config.Config.num_consecutive_builds",
|
||||
new_callable=PropertyMock, return_value = 1)
|
||||
new_callable=PropertyMock, return_value=1)
|
||||
def test_build_in_batch_fails(self, conf_num_consecutive_builds, mocked_scm,
|
||||
mocked_get_user, conf_system, dbg):
|
||||
"""
|
||||
@@ -585,7 +585,7 @@ class TestBuild(unittest.TestCase):
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
@patch("module_build_service.config.Config.num_consecutive_builds",
|
||||
new_callable=PropertyMock, return_value = 1)
|
||||
new_callable=PropertyMock, return_value=1)
|
||||
def test_all_builds_in_batch_fail(self, conf_num_consecutive_builds, mocked_scm,
|
||||
mocked_get_user, conf_system, dbg):
|
||||
"""
|
||||
|
||||
@@ -55,7 +55,7 @@ class TestFedmsgMessaging(unittest.TestCase):
|
||||
self.assertEqual(msg.build_new_state, 1)
|
||||
|
||||
@patch("module_build_service.config.Config.system",
|
||||
new_callable=PropertyMock, return_value = "copr")
|
||||
new_callable=PropertyMock, return_value="copr")
|
||||
def test_copr_build_end(self, conf_system):
|
||||
# http://fedora-fedmsg.readthedocs.io/en/latest/topics.html#copr-build-end
|
||||
copr_build_end_msg = {
|
||||
|
||||
@@ -41,7 +41,7 @@ CASSETTES_DIR = path.join(
|
||||
path.abspath(path.dirname(__file__)), '..', 'vcr-request-data')
|
||||
|
||||
@patch("module_build_service.builder.GenericBuilder.default_buildroot_groups",
|
||||
return_value = {'build': [], 'srpm-build': []})
|
||||
return_value={'build': [], 'srpm-build': []})
|
||||
@patch("module_build_service.scheduler.consumer.get_global_consumer")
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.GenericBuilder.create_from_module")
|
||||
|
||||
@@ -105,7 +105,7 @@ class TestRepoDone(unittest.TestCase):
|
||||
@mock.patch('module_build_service.builder.KojiModuleBuilder.get_session')
|
||||
@mock.patch('module_build_service.builder.KojiModuleBuilder.build')
|
||||
@mock.patch('module_build_service.builder.KojiModuleBuilder.buildroot_connect')
|
||||
@mock.patch("module_build_service.builder.GenericBuilder.default_buildroot_groups", return_value = {'build': [], 'srpm-build': []})
|
||||
@mock.patch("module_build_service.builder.GenericBuilder.default_buildroot_groups", return_value={'build': [], 'srpm-build': []})
|
||||
def test_failed_component_build(self, dbg, connect, build_fn, config, ready, list_tasks_fn):
|
||||
""" Test that when a KojiModuleBuilder.build fails, the build is
|
||||
marked as failed with proper state_reason.
|
||||
|
||||
@@ -65,7 +65,7 @@ class TestTagTagged(unittest.TestCase):
|
||||
|
||||
|
||||
@patch("module_build_service.builder.GenericBuilder.default_buildroot_groups",
|
||||
return_value = {'build': [], 'srpm-build': []})
|
||||
return_value={'build': [], 'srpm-build': []})
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.GenericBuilder.create_from_module")
|
||||
def test_newrepo(self, create_builder, koji_get_session, dbg):
|
||||
@@ -118,7 +118,7 @@ class TestTagTagged(unittest.TestCase):
|
||||
|
||||
|
||||
@patch("module_build_service.builder.GenericBuilder.default_buildroot_groups",
|
||||
return_value = {'build': [], 'srpm-build': []})
|
||||
return_value={'build': [], 'srpm-build': []})
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.GenericBuilder.create_from_module")
|
||||
def test_newrepo_still_building_components(self, create_builder, koji_get_session, dbg):
|
||||
@@ -154,7 +154,7 @@ class TestTagTagged(unittest.TestCase):
|
||||
self.assertTrue(not koji_session.newRepo.called)
|
||||
|
||||
@patch("module_build_service.builder.GenericBuilder.default_buildroot_groups",
|
||||
return_value = {'build': [], 'srpm-build': []})
|
||||
return_value={'build': [], 'srpm-build': []})
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.get_session")
|
||||
@patch("module_build_service.builder.GenericBuilder.create_from_module")
|
||||
def test_newrepo_failed_components(self, create_builder, koji_get_session, dbg):
|
||||
|
||||
@@ -63,7 +63,7 @@ class MockedSCM(object):
|
||||
|
||||
return scm_dir
|
||||
|
||||
def get_latest(self, branch = 'master'):
|
||||
def get_latest(self, branch='master'):
|
||||
return self.commit if self.commit else branch
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
@@ -87,7 +87,7 @@ class TestUtils(unittest.TestCase):
|
||||
'f25': '76f9d8c8e87eed0aab91034b01d3d5ff6bd5b4cb'}
|
||||
original_refs = ["f23", "f24", "f25"]
|
||||
|
||||
def mocked_get_latest(branch = "master"):
|
||||
def mocked_get_latest(branch="master"):
|
||||
return hashes_returned[branch]
|
||||
|
||||
mocked_scm.return_value.get_latest = mocked_get_latest
|
||||
@@ -132,7 +132,7 @@ class TestUtils(unittest.TestCase):
|
||||
'f24': '4ceea43add2366d8b8c5a622a2fb563b625b9abf',
|
||||
'f23': 'fbed359411a1baa08d4a88e0d12d426fbf8f602c',
|
||||
'f25': '76f9d8c8e87eed0aab91034b01d3d5ff6bd5b4cb'}
|
||||
def mocked_get_latest(branch = "master"):
|
||||
def mocked_get_latest(branch="master"):
|
||||
return hashes_returned[branch]
|
||||
mocked_scm.return_value.get_latest = mocked_get_latest
|
||||
|
||||
@@ -475,7 +475,7 @@ class DummyModuleBuilder(GenericBuilder):
|
||||
def list_tasks_for_components(self, component_builds=None, state='active'):
|
||||
pass
|
||||
|
||||
@patch("module_build_service.builder.GenericBuilder.default_buildroot_groups", return_value = {'build': [], 'srpm-build': []})
|
||||
@patch("module_build_service.builder.GenericBuilder.default_buildroot_groups", return_value={'build': [], 'srpm-build': []})
|
||||
class TestBatches(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -440,7 +440,7 @@ class TestViews(unittest.TestCase):
|
||||
@patch('module_build_service.scm.SCM')
|
||||
def test_submit_build_scm_parallalization(self, mocked_scm,
|
||||
mocked_get_user):
|
||||
def mocked_scm_get_latest(branch = "master"):
|
||||
def mocked_scm_get_latest(branch="master"):
|
||||
time.sleep(1)
|
||||
return branch
|
||||
|
||||
@@ -495,7 +495,7 @@ class TestViews(unittest.TestCase):
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
@patch("module_build_service.config.Config.modules_allow_repository",
|
||||
new_callable=PropertyMock, return_value = True)
|
||||
new_callable=PropertyMock, return_value=True)
|
||||
def test_submit_build_includedmodule(self, conf, mocked_scm, mocked_get_user):
|
||||
mocked_scm_obj = MockedSCM(mocked_scm, "includedmodules",
|
||||
["includedmodules.yaml", "testmodule.yaml"])
|
||||
@@ -586,7 +586,7 @@ class TestViews(unittest.TestCase):
|
||||
return_value=('sammy', set(["packager", "mbs-admin"])))
|
||||
def test_cancel_build_admin(self, mocked_get_user):
|
||||
with patch("module_build_service.config.Config.admin_groups",
|
||||
new_callable=PropertyMock, return_value = set(["mbs-admin"])):
|
||||
new_callable=PropertyMock, return_value=set(["mbs-admin"])):
|
||||
rv = self.client.patch('/module-build-service/1/module-builds/30',
|
||||
data=json.dumps({'state': 'failed'}))
|
||||
data = json.loads(rv.data)
|
||||
@@ -598,7 +598,7 @@ class TestViews(unittest.TestCase):
|
||||
return_value=('sammy', set(["packager"])))
|
||||
def test_cancel_build_no_admin(self, mocked_get_user):
|
||||
with patch("module_build_service.config.Config.admin_groups",
|
||||
new_callable=PropertyMock, return_value = set(["mbs-admin"])):
|
||||
new_callable=PropertyMock, return_value=set(["mbs-admin"])):
|
||||
rv = self.client.patch('/module-build-service/1/module-builds/30',
|
||||
data=json.dumps({'state': 'failed'}))
|
||||
data = json.loads(rv.data)
|
||||
|
||||
Reference in New Issue
Block a user