def get(self, version): """Get the plain-text test list of the specified guideline version.""" # Remove the .json from version if it is there. version.replace('.json', '') g = guidelines.Guidelines() json = g.get_guideline_contents(version) if not json: return 'Error getting JSON content for version: ' + version if pecan.request.GET.get(const.TYPE): types = pecan.request.GET.get(const.TYPE).split(',') else: types = None if pecan.request.GET.get('alias'): alias = api_utils.str_to_bool(pecan.request.GET.get('alias')) else: alias = True if pecan.request.GET.get('flag'): flag = api_utils.str_to_bool(pecan.request.GET.get('flag')) else: flag = True target = pecan.request.GET.get('target', 'platform') try: target_caps = g.get_target_capabilities(json, types, target) test_list = g.get_test_list(json, target_caps, alias, flag) except KeyError: return 'Invalid target: ' + target return '\n'.join(test_list)
def get_one(self, file_name): """Handler for getting contents of specific guideline file.""" g = guidelines.Guidelines() json = g.get_guideline_contents(file_name) if json: return json else: pecan.abort(500, 'The server was unable to get the JSON ' 'content for the specified guideline file.')
def get(self): """Get a list of all available guidelines.""" g = guidelines.Guidelines() version_list = g.get_guideline_list() if version_list is None: pecan.abort(500, 'The server was unable to get a list of ' 'guidelines from the external source.') else: return version_list
def setUp(self): super(GuidelinesTestCase, self).setUp() self.guidelines = guidelines.Guidelines()