def _get_repos_by_backend(self): # # return dict with backend and list of repositories # output = {} projects = TaskProjects.get_projects() for backend_section in Config.get_backend_sections(): for pro in projects: backend = Task.get_backend(backend_section) if backend in projects[pro]: if backend_section not in output: output[backend_section] = projects[pro][backend] else: output[backend_section] += projects[pro][backend] # backend could be in project/repo file but not enabled in # sirmordred conf file enabled = {} for k in output: if k in self.conf: enabled[k] = output[k] # logger.debug('repos to be retrieved: %s ', enabled) return enabled
def test_run_eclipse(self): """Test whether the Task could be run getting projects from Eclipse""" setup_http_server() # Create a empty projects file for testing projects_file = 'test-projects-eclipse.json' config = Config(CONF_FILE) config.set_param('projects', 'load_eclipse', True) config.set_param('projects', 'projects_file', projects_file) task = TaskProjects(config) self.assertEqual(task.execute(), None) self.assertEqual(len(task.get_projects().keys()), 302) # Let's remove some projects to track changes with open(ECLIPSE_PROJECTS_FILE) as eproj: remove_project = 'birt' add_project = 'new_project' new_projects = task.convert_from_eclipse( json.load(eproj)['projects']) new_projects.pop(remove_project) new_projects.update({add_project: {}}) task.set_projects(new_projects) self.assertEqual(task.get_projects_last_diff().sort(), [add_project, remove_project].sort()) remove(projects_file)
def _get_repos_by_backend(self): # # return dict with backend and list of repositories # output = {} projects = TaskProjects.get_projects() for pro in projects: # remove duplicates in backends_section with list(set(..)) backend_sections = list( set([ sect for sect in projects[pro].keys() for backend_section in Config.get_backend_sections() if sect and sect.startswith(backend_section) ])) # sort backends section backend_sections.sort() for backend_section in backend_sections: if backend_section not in output: output[backend_section] = projects[pro][backend_section] else: output[backend_section] += projects[pro][backend_section] # backend could be in project/repo file but not enabled in # sirmordred conf file enabled = {} for k in output: if k in self.conf: enabled[k] = output[k] # logger.debug('repos to be retrieved: %s ', enabled) return enabled
def test__get_projects_from_url(self): """Test downloading projects from an URL """ setup_http_server() projects_url = 'http://localhost/projects.json' config = Config(CONF_FILE) config.set_param('projects', 'projects_url', projects_url) task = TaskProjects(config) self.assertEqual(task.execute(), None) projects = task.get_projects() self.assertTrue(URL_PROJECTS_MAIN in projects)
def test_run_eclipse(self): """Test whether the Task could be run getting projects from Eclipse""" setup_http_server() # Create a empty projects file for testing projects_file = 'test-projects-eclipse.json' config = Config(CONF_FILE) config.set_param('projects', 'load_eclipse', True) config.set_param('projects', 'projects_file', projects_file) task = TaskProjects(config) self.assertEqual(task.execute(), None) self.assertEqual(len(task.get_projects().keys()), 302) remove(projects_file)
def test_convert_from_eclipse(self): """Test the conversion from eclipse projects to grimoire projects""" setup_http_server() projects_file = 'test-projects-eclipse.json' config = Config(CONF_FILE) config.set_param('projects', 'load_eclipse', True) config.set_param('projects', 'projects_file', projects_file) task = TaskProjects(config) self.assertEqual(task.execute(), None) projects = task.get_projects() self.assertTrue(TaskProjects.GLOBAL_PROJECT in projects) self.assertEqual(projects['birt']['github'][0], 'https://github.com/eclipse/birt') remove(projects_file)
def test_run(self): """Test whether the Task could be run""" config = Config(CONF_FILE) task = TaskProjects(config) self.assertEqual(task.execute(), None) self.assertEqual(len(task.get_projects().keys()), 1)