diff --git a/app/appdb.py b/app/appdb.py index cd1a68394..f6a72a0a5 100644 --- a/app/appdb.py +++ b/app/appdb.py @@ -131,12 +131,13 @@ def get_images(site_id, vo): va_data = appdb_call('/rest/1.0/va_providers/%s' % site_id) images = [] - if 'provider:image' in va_data['virtualization:provider'] and va_data['virtualization:provider']['provider:image']: + if ('provider:image' in va_data['virtualization:provider'] and + va_data['virtualization:provider']['provider:image']): if isinstance(va_data['virtualization:provider']['provider:image'], list): images = va_data['virtualization:provider']['provider:image'] else: images = [va_data['virtualization:provider']['provider:image']] - + for os_tpl in images: try: if '@voname' in os_tpl and vo in os_tpl['@voname'] and os_tpl['@archived'] == "false": @@ -144,7 +145,7 @@ def get_images(site_id, vo): except Exception: continue except Exception: - pass + oss = [] return oss diff --git a/app/tests/test_appdb.py b/app/tests/test_appdb.py index 9a2b22e78..012bab65a 100644 --- a/app/tests/test_appdb.py +++ b/app/tests/test_appdb.py @@ -123,7 +123,6 @@ def test_get_project_ids(self, appdb_call): self.assertEquals(res, {"vo.access.egi.eu": "3a8e9d966e644405bf19b536adf7743d", "covid-19.eosc-synergy.eu": "972298c557184a2192ebc861f3184da8"}) - @patch('app.appdb.appdb_call') def test_get_images(self, appdb_call): images = """ @@ -133,5 +132,6 @@ def test_get_images(self, appdb_call): res = appdb.get_images('11548G0', 'vo.access.egi.eu') self.assertEquals(res, ["scipioncloud.gpu"]) + if __name__ == '__main__': unittest.main()