Fix formatting issues

Code should be formatted via black.

Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2020-02-07 13:53:20 +08:00
parent 56fea60595
commit 9b12be7300
5 changed files with 46 additions and 43 deletions

View File

@ -90,9 +90,7 @@ class GatherMethodNodeps(pungi.phases.gather.method.GatherMethodBase):
and pkg.arch != "noarch" and pkg.arch != "noarch"
): ):
continue continue
result["rpm"].append( result["rpm"].append({"path": pkg.file_path, "flags": ["input"]})
{"path": pkg.file_path, "flags": ["input"]}
)
seen_rpms.setdefault(pkg.name, set()).add(pkg.arch) seen_rpms.setdefault(pkg.name, set()).add(pkg.arch)
seen_srpms.setdefault(pkg.sourcerpm, set()).add(pkg.arch) seen_srpms.setdefault(pkg.sourcerpm, set()).add(pkg.arch)
log.write( log.write(
@ -105,9 +103,7 @@ class GatherMethodNodeps(pungi.phases.gather.method.GatherMethodBase):
if not pkg_is_srpm(pkg): if not pkg_is_srpm(pkg):
continue continue
if pkg.file_name in seen_srpms: if pkg.file_name in seen_srpms:
result["srpm"].append( result["srpm"].append({"path": pkg.file_path, "flags": ["input"]})
{"path": pkg.file_path, "flags": ["input"]}
)
log.write("Adding %s\n" % pkg) log.write("Adding %s\n" % pkg)
log.write("\nGathering debuginfo packages\n") log.write("\nGathering debuginfo packages\n")
@ -125,9 +121,7 @@ class GatherMethodNodeps(pungi.phases.gather.method.GatherMethodBase):
# pull debuginfo (they would pull in all architectures). # pull debuginfo (they would pull in all architectures).
log.write("Not including %s: no package for this arch\n" % pkg) log.write("Not including %s: no package for this arch\n" % pkg)
continue continue
result["debuginfo"].append( result["debuginfo"].append({"path": pkg.file_path, "flags": ["input"]})
{"path": pkg.file_path, "flags": ["input"]}
)
log.write("Adding %s\n" % pkg) log.write("Adding %s\n" % pkg)
return result return result

View File

@ -143,9 +143,7 @@ class OSBSThread(WorkerThread):
result = koji.koji_proxy.getTaskResult(task_id) result = koji.koji_proxy.getTaskResult(task_id)
if is_scratch: if is_scratch:
metadata.update( metadata.update({"repositories": result["repositories"]})
{"repositories": result["repositories"]}
)
# add a fake arch of 'scratch', so we can construct the metadata # add a fake arch of 'scratch', so we can construct the metadata
# in same data structure as real builds. # in same data structure as real builds.
self.pool.metadata.setdefault(variant.uid, {}).setdefault( self.pool.metadata.setdefault(variant.uid, {}).setdefault(

View File

@ -181,20 +181,26 @@ def main(args=None):
), ),
) )
parser.add_argument( parser.add_argument(
'--schema-override', "--schema-override",
action="append", action="append",
default=[], default=[],
help=( help=(
'Path to extra JSON schema defining the values which will override ' "Path to extra JSON schema defining the values which will override "
'the original Pungi JSON schema values.' "the original Pungi JSON schema values."
), ),
) )
opts = parser.parse_args(args) opts = parser.parse_args(args)
defines = config_utils.extract_defines(opts.define) defines = config_utils.extract_defines(opts.define)
with pungi.util.temp_dir() as topdir: with pungi.util.temp_dir() as topdir:
errors = run(opts.config, topdir, opts.old_composes, opts.offline, defines, errors = run(
opts.schema_override) opts.config,
topdir,
opts.old_composes,
opts.offline,
defines,
opts.schema_override,
)
for msg in errors: for msg in errors:
print(msg) print(msg)

View File

@ -582,12 +582,8 @@ class TestSchemaValidator(unittest.TestCase):
"definitions": { "definitions": {
"scm_dict": { "scm_dict": {
"properties": { "properties": {
"scm": { "scm": {"enum": ["git"]},
"enum": ["git"] "repo": {"enum": ["git://localhost/pungi-fedora.git"]},
},
"repo": {
"enum": ["git://localhost/pungi-fedora.git"]
},
} }
} }
} }
@ -595,11 +591,12 @@ class TestSchemaValidator(unittest.TestCase):
schema = checks.update_schema(schema, schema_override) schema = checks.update_schema(schema, schema_override)
scm_dict_properties = schema["definitions"]["scm_dict"]["properties"] scm_dict_properties = schema["definitions"]["scm_dict"]["properties"]
self.assertEqual( self.assertEqual(
scm_dict_properties["scm"], scm_dict_properties["scm"], {"enum": ["git"], "type": "string"}
{'enum': ['git'], 'type': 'string'}) )
self.assertEqual( self.assertEqual(
scm_dict_properties["repo"], scm_dict_properties["repo"],
{'enum': ['git://localhost/pungi-fedora.git'], 'type': 'string'}) {"enum": ["git://localhost/pungi-fedora.git"], "type": "string"},
)
self.assertEqual(scm_dict_properties["file"], {"type": "string"}) self.assertEqual(scm_dict_properties["file"], {"type": "string"})

View File

@ -10,29 +10,37 @@ from tests import helpers
HERE = os.path.abspath(os.path.dirname(__file__)) HERE = os.path.abspath(os.path.dirname(__file__))
DUMMY_CONFIG = os.path.join(HERE, 'data/dummy-pungi.conf') DUMMY_CONFIG = os.path.join(HERE, "data/dummy-pungi.conf")
SCHEMA_OVERRIDE = os.path.join(HERE, 'data/dummy-override.json') SCHEMA_OVERRIDE = os.path.join(HERE, "data/dummy-override.json")
class ConfigValidateScriptTest(helpers.PungiTestCase): class ConfigValidateScriptTest(helpers.PungiTestCase):
@mock.patch("sys.argv", new=["pungi-config-validate", DUMMY_CONFIG])
@mock.patch('sys.argv', new=['pungi-config-validate', DUMMY_CONFIG]) @mock.patch("sys.stderr", new_callable=six.StringIO)
@mock.patch('sys.stderr', new_callable=six.StringIO) @mock.patch("sys.stdout", new_callable=six.StringIO)
@mock.patch('sys.stdout', new_callable=six.StringIO)
def test_validate_dummy_config(self, stdout, stderr): def test_validate_dummy_config(self, stdout, stderr):
cli_main() cli_main()
self.assertEqual('', stdout.getvalue()) self.assertEqual("", stdout.getvalue())
self.assertEqual('', stderr.getvalue()) self.assertEqual("", stderr.getvalue())
@mock.patch('sys.argv', new=[ @mock.patch(
'pungi-config-validate', DUMMY_CONFIG, "--schema-override", "sys.argv",
SCHEMA_OVERRIDE]) new=[
@mock.patch('sys.stderr', new_callable=six.StringIO) "pungi-config-validate",
@mock.patch('sys.stdout', new_callable=six.StringIO) DUMMY_CONFIG,
@mock.patch('sys.exit') "--schema-override",
SCHEMA_OVERRIDE,
],
)
@mock.patch("sys.stderr", new_callable=six.StringIO)
@mock.patch("sys.stdout", new_callable=six.StringIO)
@mock.patch("sys.exit")
def test_schema_override(self, exit, stdout, stderr): def test_schema_override(self, exit, stdout, stderr):
cli_main() cli_main()
self.assertTrue(stdout.getvalue().startswith( self.assertTrue(
"Failed validation in pkgset_source: 'repos' is not one of")) stdout.getvalue().startswith(
self.assertEqual('', stderr.getvalue()) "Failed validation in pkgset_source: 'repos' is not one of"
)
)
self.assertEqual("", stderr.getvalue())
exit.assert_called_once_with(1) exit.assert_called_once_with(1)