Example #1
0
  def test_get_projects_yaml(self):
    """Testing get_projects() yaml get_schedule()."""

    repo = Repository('oss-fuzz', 'dir', 'projects', [
        Repository('test0', 'dir', 'projects/test0', [
            Repository('Dockerfile', 'file', 'projects/test0/Dockerfile'),
            Repository('project.yaml', 'file', 'projects/test0/project.yaml')
        ]),
        Repository('test1', 'dir', 'projects/test1', [
            Repository('Dockerfile', 'file', 'projects/test1/Dockerfile'),
            Repository('project.yaml', 'file', 'projects/test1/project.yaml')
        ])
    ])
    repo.contents[0].contents[1].set_yaml_contents(b'builds_per_day: 2')
    repo.contents[1].contents[1].set_yaml_contents(b'builds_per_day: 3')

    self.assertEqual(
        get_projects(repo), {
            'test0':
                ProjectMetadata('0 6,18 * * *', 'builds_per_day: 2',
                                'name: test'),
            'test1':
                ProjectMetadata('0 6,14,22 * * *', 'builds_per_day: 3',
                                'name: test')
        })
Example #2
0
  def test_sync_projects_update(self):
    """Testing sync_projects() updating a schedule."""
    client = ndb.Client()
    cloud_scheduler_client = CloudSchedulerClient()

    with client.context():
      Project(name='test1',
              schedule='0 8 * * *',
              project_yaml_contents='',
              dockerfile_contents='').put()
      Project(name='test2',
              schedule='0 9 * * *',
              project_yaml_contents='',
              dockerfile_contents='').put()

      projects = {
          'test1': ProjectMetadata('0 8 * * *', '', ''),
          'test2': ProjectMetadata('0 7 * * *', '', '')
      }
      sync_projects(cloud_scheduler_client, projects)

      projects_query = Project.query()
      self.assertEqual({
          'test1': '0 8 * * *',
          'test2': '0 7 * * *'
      }, {project.name: project.schedule for project in projects_query})
Example #3
0
  def test_get_projects_non_directory_type_project(self):
    """Testing get_projects() when a file in projects/ is not of type 'dir'."""

    repo = Repository('oss-fuzz', 'dir', 'projects', [
        Repository('test0', 'dir', 'projects/test0', [
            Repository('Dockerfile', 'file', 'projects/test0/Dockerfile'),
            Repository('project.yaml', 'file', 'projects/test0/project.yaml')
        ]),
        Repository('test1', 'file', 'projects/test1')
    ])

    self.assertEqual(
        get_projects(repo),
        {'test0': ProjectMetadata('0 6 * * *', 'name: test', 'name: test')})
Example #4
0
  def test_get_projects_no_docker_file(self):
    """Testing get_projects() with missing dockerfile"""

    repo = Repository('oss-fuzz', 'dir', 'projects', [
        Repository('test0', 'dir', 'projects/test0', [
            Repository('Dockerfile', 'file', 'projects/test0/Dockerfile'),
            Repository('project.yaml', 'file', 'projects/test0/project.yaml')
        ]),
        Repository('test1', 'dir', 'projects/test1')
    ])

    self.assertEqual(
        get_projects(repo),
        {'test0': ProjectMetadata('0 6 * * *', 'name: test', 'name: test')})