Beispiel #1
0
    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 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
        # mordred 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
Beispiel #3
0
    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
        # mordred 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
Beispiel #4
0
    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_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)

        remove(projects_file)
Beispiel #6
0
    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)
Beispiel #7
0
 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)