Esempio n. 1
0
    def test_exclusions(self):
        project = 'test'
        repo = 'test'

        controller.REPO_EXCLUSIONS.setdefault(project, []).append(repo)
        my_repo = model_helpers.create_repo()
        my_repo.project = project
        my_repo.repo = repo
        my_repo.put()

        active_repos = controller.get_active_repos(project)
        self.assertEqual([], active_repos)
Esempio n. 2
0
  def test_exclusions(self):
    project = 'test'
    repo = 'test'

    controller.REPO_EXCLUSIONS.setdefault(project, []).append(repo)
    my_repo = model_helpers.create_repo()
    my_repo.project = project
    my_repo.repo = repo
    my_repo.put()

    active_repos = controller.get_active_repos(project)
    self.assertEqual([], active_repos)
Esempio n. 3
0
  def test_project_repo_scan(self):
    my_project = model_helpers.create_project()
    my_project.put()
    base_url = my_project.canonical_url_template % {'project': my_project.name}

    repo_data = {'cool_src': {}}
    log_data = {u'log': []}

    with self.mock_urlfetch() as urlfetch:
      urlfetch.register_handler(
          base_url + '?format=json&n=1000',
          self._gitiles_json(repo_data))
      urlfetch.register_handler(
          base_url + 'cool_src/+log/master?format=json&n=1',
          self._gitiles_json(log_data))

    controller.scan_projects_for_repos()
    self.execute_queued_tasks()
    self.assertEquals(1, len(controller.get_active_repos(my_project.name)))
Esempio n. 4
0
    def test_project_repo_scan(self):
        my_project = model_helpers.create_project()
        my_project.put()
        base_url = my_project.canonical_url_template % {
            'project': my_project.name
        }

        repo_data = {'cool_src': {}}
        log_data = {u'log': []}

        with self.mock_urlfetch() as urlfetch:
            urlfetch.register_handler(base_url + '?format=json&n=1000',
                                      self._gitiles_json(repo_data))
            urlfetch.register_handler(
                base_url + 'cool_src/+log/master?format=json&n=1',
                self._gitiles_json(log_data))

        controller.scan_projects_for_repos()
        self.execute_queued_tasks()
        self.assertEquals(1, len(controller.get_active_repos(my_project.name)))
Esempio n. 5
0
    def test_project_repo_scan_active(self):
        my_project = model_helpers.create_project()
        my_project.put()
        base_url = my_project.canonical_url_template % {
            'project': my_project.name
        }

        repo_data = {
            'cool_src': {},
            'cooler_src': {},
            'uncool_src': {},
        }
        log_data = {u'log': []}

        with self.mock_urlfetch() as urlfetch:
            urlfetch.register_handler(base_url + '?format=json&n=1000',
                                      self._gitiles_json(repo_data))
            urlfetch.register_handler(
                base_url + 'cool_src/+log/master?format=json&n=1',
                self._gitiles_json(log_data))
            urlfetch.register_handler(
                base_url + 'cooler_src/+log/master?format=json&n=1',
                self._gitiles_json(log_data))
            # Don't handle uncool_src, making it nonreal.

        controller.scan_projects_for_repos()
        self.execute_queued_tasks()
        self.assertEquals(2, len(controller.get_active_repos(my_project.name)))

        # Now test that active repos are inactive when they go away.
        repo_data = {
            'cooler_src': {},
        }
        with self.mock_urlfetch() as urlfetch:
            urlfetch.register_handler(base_url + '?format=json&n=1000',
                                      self._gitiles_json(repo_data))
            urlfetch.register_handler(
                base_url + 'cooler_src/+log/master?format=json&n=1',
                self._gitiles_json(log_data))

        controller.scan_projects_for_repos()
        self.execute_queued_tasks()
        self.assertEquals(1, len(controller.get_active_repos(my_project.name)))

        # And test that they can come back.
        repo_data = {
            'cool_src': {},
            'cooler_src': {},
        }
        with self.mock_urlfetch() as urlfetch:
            urlfetch.register_handler(base_url + '?format=json&n=1000',
                                      self._gitiles_json(repo_data))
            urlfetch.register_handler(
                base_url + 'cool_src/+log/master?format=json&n=1',
                self._gitiles_json(log_data))
            urlfetch.register_handler(
                base_url + 'cooler_src/+log/master?format=json&n=1',
                self._gitiles_json(log_data))
        controller.scan_projects_for_repos()
        self.execute_queued_tasks()
        self.assertEquals(2, len(controller.get_active_repos(my_project.name)))
Esempio n. 6
0
  def test_project_repo_scan_active(self):
    my_project = model_helpers.create_project()
    my_project.put()
    base_url = my_project.canonical_url_template % {'project': my_project.name}

    repo_data = {
      'cool_src': {},
      'cooler_src': {},
      'uncool_src': {},
    }
    log_data = {u'log': []}

    with self.mock_urlfetch() as urlfetch:
      urlfetch.register_handler(
          base_url + '?format=json&n=1000',
          self._gitiles_json(repo_data))
      urlfetch.register_handler(
          base_url + 'cool_src/+log/master?format=json&n=1',
          self._gitiles_json(log_data))
      urlfetch.register_handler(
          base_url + 'cooler_src/+log/master?format=json&n=1',
          self._gitiles_json(log_data))
      # Don't handle uncool_src, making it nonreal.

    controller.scan_projects_for_repos()
    self.execute_queued_tasks()
    self.assertEquals(2, len(controller.get_active_repos(my_project.name)))

    # Now test that active repos are inactive when they go away.
    repo_data = {
      'cooler_src': {},
    }
    with self.mock_urlfetch() as urlfetch:
      urlfetch.register_handler(
          base_url + '?format=json&n=1000',
          self._gitiles_json(repo_data))
      urlfetch.register_handler(
          base_url + 'cooler_src/+log/master?format=json&n=1',
          self._gitiles_json(log_data))

    controller.scan_projects_for_repos()
    self.execute_queued_tasks()
    self.assertEquals(1, len(controller.get_active_repos(my_project.name)))

    # And test that they can come back.
    repo_data = {
      'cool_src': {},
      'cooler_src': {},
    }
    with self.mock_urlfetch() as urlfetch:
      urlfetch.register_handler(
          base_url + '?format=json&n=1000',
          self._gitiles_json(repo_data))
      urlfetch.register_handler(
          base_url + 'cool_src/+log/master?format=json&n=1',
          self._gitiles_json(log_data))
      urlfetch.register_handler(
          base_url + 'cooler_src/+log/master?format=json&n=1',
          self._gitiles_json(log_data))
    controller.scan_projects_for_repos()
    self.execute_queued_tasks()
    self.assertEquals(2, len(controller.get_active_repos(my_project.name)))