From ea77df11bd0e67216a96fcbf6f0ce1fb12deec63 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Oct 13 2017 06:04:31 +0000 Subject: Return found content sets in list Returning those content sets in set type could make it fail to serialize images from dict to JSON data, e.g. by calling json.dumps. Signed-off-by: Chenxiong Qi --- diff --git a/freshmaker/lightblue.py b/freshmaker/lightblue.py index 8b8cc2b..27c55b2 100644 --- a/freshmaker/lightblue.py +++ b/freshmaker/lightblue.py @@ -419,6 +419,9 @@ class LightBlue(object): repositories :param str release_category: filter only repositories with specific release category (options: Deprecated, Generally Available, Beta, Tech Preview) + :return: list of found content sets, each of which is content set name. + Empty list is returned if no repository is found. + :rtype: list """ repo_request = { "objectType": "containerRepository", @@ -452,13 +455,13 @@ class LightBlue(object): } repos = self.find_container_repositories(repo_request) if not repos: - return set() + return [] ret = set() for repo in repos: ret |= set(repo["content_sets"]) - return ret + return sorted(list(ret)) def _get_default_projection(self): return [ diff --git a/tests/test_lightblue.py b/tests/test_lightblue.py index 3aebc40..719e227 100644 --- a/tests/test_lightblue.py +++ b/tests/test_lightblue.py @@ -684,7 +684,7 @@ class TestQueryEntityFromLightBlue(unittest.TestCase): "package": "package-name-1" }, 'repositories': [{'repository': 'product1/repo1', 'published': True}], - 'content_sets': set(['dummy-content-set-1', 'dummy-content-set-2']), + 'content_sets': ['dummy-content-set-1', 'dummy-content-set-2'], 'parsed_data': { 'files': [ { @@ -717,7 +717,7 @@ class TestQueryEntityFromLightBlue(unittest.TestCase): "build": "package-name-2-4-12.10", "package": "package-name-2" }, - 'content_sets': set(['dummy-content-set-1', 'dummy-content-set-2']), + 'content_sets': ['dummy-content-set-1', 'dummy-content-set-2'], 'repositories': [{'repository': 'product2/repo2', 'published': True}], 'parsed_data': { 'files': [