def test_getting_images_when_response_is_ok_and_filtering_on_creator(self): api = AtmosphereAPI('token', base_url=self.mock_users_base_url) response = api.get_images(created_by='jfischer') assert response.ok results = response.message['results'] fcount = 0 for r in results: if is_term_in_image_result(r, 'jfischer'): fcount += 1 assert response.message['count'] == 9 and fcount == 9
def test_getting_images_when_response_is_ok_and_filtering_on_tag(self): api = AtmosphereAPI('token', base_url=self.mock_users_base_url) response = api.get_images(tag_name='docker') assert response.ok results = response.message['results'] fcount = 0 for r in results: if is_term_in_image_result(r, 'docker'): fcount += 1 assert response.message['count'] == 11 and fcount == 11
def take_action(self, parsed_args): column_headers = ('uuid', 'name', 'created_by', 'is_public', 'start_date') api = AtmosphereAPI(self.app_args.auth_token, base_url=self.app_args.base_url, timeout=self.app_args.api_server_timeout, verify=self.app_args.verify_cert) data = api.get_images(parsed_args.tag_name, parsed_args.created_by, parsed_args.project_id) images = [] if data.ok: for image in data.message['results']: start_date = ts_to_isodate(image['start_date']) images.append( (image['uuid'], image['name'], image['created_by']['username'], image['is_public'], start_date if start_date else image['start_date'])) return (column_headers, tuple(images))
def test_getting_images_when_response_is_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_base_url) response = api.get_images() assert response.ok assert response.message['count'] == 10 and response.message['results'][0]['name'] == 'Centos 7 (7.4) Development GUI'
def test_getting_images_when_response_is_not_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_bad_base_url) response = api.get_images() assert not response.ok