def get_one(self, test_id): """Handler for getting item.""" user_role = api_utils.get_user_role(test_id) if user_role in (const.ROLE_FOUNDATION, const.ROLE_OWNER): test_info = db.get_test(test_id, allowed_keys=[ 'id', 'cpid', 'created_at', 'duration_seconds', 'meta', 'product_version', 'verification_status' ]) else: test_info = db.get_test(test_id) test_list = db.get_test_results(test_id) test_name_list = [test_dict['name'] for test_dict in test_list] test_info.update({'results': test_name_list, 'user_role': user_role}) if user_role not in (const.ROLE_FOUNDATION, const.ROLE_OWNER): # Don't expose product information if product is not public. if (test_info.get('product_version') and not test_info['product_version']['product_info']['public'] ): test_info['product_version'] = None test_info['meta'] = { k: v for k, v in test_info['meta'].items() if k in MetadataController.rw_access_keys } return test_info
def get_one(self, test_id): """Handler for getting item.""" if api_utils.get_user_role(test_id) == const.ROLE_OWNER: test_info = db.get_test(test_id, allowed_keys=["id", "cpid", "created_at", "duration_seconds", "meta"]) else: test_info = db.get_test(test_id) test_list = db.get_test_results(test_id) test_name_list = [test_dict["name"] for test_dict in test_list] test_info.update({"results": test_name_list, "user_role": api_utils.get_user_role(test_id)}) return test_info
def get_item(self, item_id): """Handler for getting item""" test_info = db.get_test(item_id) if not test_info: pecan.abort(404) test_list = db.get_test_results(item_id) test_name_list = [test_dict[0] for test_dict in test_list] return {"cpid": test_info.cpid, "created_at": test_info.created_at, "duration_seconds": test_info.duration_seconds, "results": test_name_list}
def get_item(self, item_id): """Handler for getting item""" test_info = db.get_test(item_id) if not test_info: pecan.abort(404) test_list = db.get_test_results(item_id) test_name_list = [test_dict[0] for test_dict in test_list] return { "cpid": test_info.cpid, "created_at": test_info.created_at, "duration_seconds": test_info.duration_seconds, "results": test_name_list }
def get_one(self, test_id): """Handler for getting item.""" if api_utils.get_user_role(test_id) == const.ROLE_OWNER: test_info = db.get_test( test_id, allowed_keys=['id', 'cpid', 'created_at', 'duration_seconds', 'meta'] ) else: test_info = db.get_test(test_id) test_list = db.get_test_results(test_id) test_name_list = [test_dict['name'] for test_dict in test_list] test_info.update({'results': test_name_list, 'user_role': api_utils.get_user_role(test_id)}) return test_info
def get_one(self, test_id): """Handler for getting item.""" if api_utils.get_user_role(test_id) == const.ROLE_OWNER: test_info = db.get_test( test_id, allowed_keys=['id', 'cpid', 'created_at', 'duration_seconds', 'meta'] ) else: test_info = db.get_test(test_id) test_list = db.get_test_results(test_id) test_name_list = [test_dict['name'] for test_dict in test_list] test_info.update({'results': test_name_list, 'user_role': api_utils.get_user_role(test_id)}) cloud_id = test_info['cpid'] cloud = db.get_cloud(cloud_id) if cloud: test_info.update({'cloud_name': cloud['name'], 'cloud_description': cloud['description'], 'cloud_shared': cloud['shared']}) return test_info
def test_get_test_results(self, mock_get_test_results): db.get_test_results(12345) mock_get_test_results.assert_called_once_with(12345)