commit
ef043e2c14
4 changed files with 17 additions and 4 deletions
|
|
@ -42,6 +42,8 @@ The build map contains the following entries:
|
|||
- start\_time: The time the build started, in seconds since the epoch.
|
||||
- end\_time: The time the build was completed, in seconds since the
|
||||
epoch.
|
||||
- owner: The owner of the build task in username format. This field
|
||||
is optional.
|
||||
- extra: A map of extra metadata associated with the build, which
|
||||
must include one of:
|
||||
|
||||
|
|
@ -157,7 +159,8 @@ The below JSON is based loosely on the output of a docker image build.
|
|||
"source": "git://git.engineering.redhat.com/users/vpavlin/tdl_templates.git#a14f145244",
|
||||
"extra": {},
|
||||
"start_time": 1423148398,
|
||||
"end_time": 1423148828},
|
||||
"end_time": 1423148828,
|
||||
"owner": "jdoe"},
|
||||
"buildroots": [{"id": 1,
|
||||
"host": {"os": "rhel-7",
|
||||
"arch": "x86_64"},
|
||||
|
|
|
|||
|
|
@ -5095,6 +5095,11 @@ class CG_Importer(object):
|
|||
datetime.datetime.fromtimestamp(float(metadata['build']['start_time'])).isoformat(' ')
|
||||
buildinfo['completion_time'] = \
|
||||
datetime.datetime.fromtimestamp(float(metadata['build']['end_time'])).isoformat(' ')
|
||||
owner = metadata['build'].get('owner', None)
|
||||
if owner:
|
||||
if not isinstance(owner, basestring):
|
||||
raise koji.GenericError("Invalid owner format (expected username): %s" % owner)
|
||||
buildinfo['owner'] = get_user(owner, strict=True)['id']
|
||||
self.buildinfo = buildinfo
|
||||
|
||||
koji.check_NVR(buildinfo, strict=True)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
"source": "git://git.engineering.redhat.com/users/vpavlin/tdl_templates.git#a14f145244",
|
||||
"extra": {},
|
||||
"start_time": 1423148398,
|
||||
"end_time": 1423148828},
|
||||
"end_time": 1423148828,
|
||||
"owner": "koji"},
|
||||
"buildroots": [{"id": 1,
|
||||
"host": {"os": "rhel-7",
|
||||
"arch": "x86_64"},
|
||||
|
|
|
|||
|
|
@ -68,12 +68,14 @@ class TestCGImporter(unittest.TestCase):
|
|||
assert x.cgs
|
||||
assert isinstance(x.cgs, set)
|
||||
|
||||
@mock.patch("kojihub.get_user")
|
||||
@mock.patch('kojihub.context')
|
||||
@mock.patch("koji.pathinfo.work")
|
||||
def test_prep_build(self, work, context):
|
||||
def test_prep_build(self, work, context, get_user):
|
||||
work.return_value = os.path.dirname(__file__)
|
||||
cursor = mock.MagicMock()
|
||||
context.cnx.cursor.return_value = cursor
|
||||
get_user.return_value = {'id': 123}
|
||||
x = kojihub.CG_Importer()
|
||||
x.get_metadata('default.json', 'cg_importer_json')
|
||||
x.prep_build()
|
||||
|
|
@ -90,16 +92,18 @@ class TestCGImporter(unittest.TestCase):
|
|||
with self.assertRaises(GenericError):
|
||||
x.prep_build()
|
||||
|
||||
@mock.patch("kojihub.get_user")
|
||||
@mock.patch('kojihub.get_build')
|
||||
@mock.patch('kojihub.new_build')
|
||||
@mock.patch('kojihub.context')
|
||||
@mock.patch("koji.pathinfo.work")
|
||||
def test_get_build(self, work, context, new_build_id, get_build):
|
||||
def test_get_build(self, work, context, new_build_id, get_build, get_user):
|
||||
work.return_value = os.path.dirname(__file__)
|
||||
cursor = mock.MagicMock()
|
||||
context.cnx.cursor.return_value = cursor
|
||||
new_build_id.return_value = 42
|
||||
get_build.return_value = False
|
||||
get_user.return_value = {'id': 123}
|
||||
x = kojihub.CG_Importer()
|
||||
x.get_metadata('default.json', 'cg_importer_json')
|
||||
x.prep_build()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue