def test_searching_images_when_response_is_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_base_url) response = api.search_images('galaxy') assert response.ok results = response.message['results'] fcount = 0 for r in results: if is_term_in_image_result(r, 'galaxy'): fcount += 1 assert response.message['count'] == 3 and fcount == 3
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.search_images(parsed_args.search_term) 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))