Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
consumer: Refactor the code to handle F28 Two week atomic
Browse files Browse the repository at this point in the history
Signed-off-by: Sayan Chowdhury <[email protected]>
  • Loading branch information
sayanchowdhury committed Apr 27, 2018
1 parent b4a3e58 commit 4b218f6
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 1,184 deletions.
19 changes: 9 additions & 10 deletions fedimg/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def consume(self, msg):
_log.debug("%r is unsupported compose" % compose_id)
return


# Till F27, both cloud-base and atomic images were available
# under variant CloudImages. With F28 and onward releases,
# cloud-base image compose moved to cloud variant and atomic images
Expand All @@ -99,19 +98,19 @@ def consume(self, msg):
compose_metadata, 'images', 'payload', 'images', 'CloudImages',
'x86_64')
else:
images_meta = get_value_from_dict(
cloud_meta = get_value_from_dict(
compose_metadata, 'images', 'payload', 'images',
'Cloud', 'x86_64')
if images_meta is None:
images_meta = get_value_from_dict(
compose_metadata, 'images', 'payload',
'images', 'AtomicHost', 'x86_64')
atomic_meta = get_value_from_dict(
compose_metadata, 'images', 'payload',
'images', 'AtomicHost', 'x86_64')

if (cloud_meta and atomic_meta) is None:
images_meta = cloud_meta or atomic_meta
else:
images_meta.extend(get_value_from_dict(
compose_metadata, 'images', 'payload',
'images', 'AtomicHost', 'x86_64'))
images_meta = cloud_meta + atomic_meta

if images_meta is None:
if not images_meta:
_log.debug('No compatible image found to process')
return

Expand Down
9 changes: 4 additions & 5 deletions tests/test_consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,20 @@ def test_incompatible_images(self, mock_upload, mock_log):
"release_type": "ga",
"compose_label": None,
"compose_respin": 0,
"compose_date": "20180321",
"release_version": "28",
"location": "http://kojipkgs.fedoraproject.org/compose/branched/Fedora-28-20180321.n.0/compose",
"compose_date": "20180426",
"release_version": "Rawhide",
"location": "http://kojipkgs.fedoraproject.org/compose/rawhide/Fedora-Rawhide-20180426.n.0/compose",
"compose_type": "nightly",
"release_is_layered": False,
"release_name": "Fedora",
"release_short": "Fedora",
"compose_id": "Fedora-28-20180321.n.0"
"compose_id": "Fedora-Rawhide-20180426.n.0"
}
}
}
self.consumer.consume(msg)
mock_log.assert_called_with('No compatible image found to process')


@mock.patch('fedimg.uploader.upload')
def test_success_upload(self, upload):
msg = {
Expand Down
Loading

0 comments on commit 4b218f6

Please sign in to comment.