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') })
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('test1', 'file', 'projects/test1') ]) self.assertEqual(get_projects(repo), {'test0'})
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('test1', 'dir', 'projects/test1') ]) self.assertEqual(get_projects(repo), {'test0'})
def test_yaml_out_of_range(self): """Testing invalid yaml schedule parameter argument.""" 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') ]) ]) repo.contents[0].contents[1].set_yaml_contents(b'builds_per_day: 5') self.assertEqual(get_projects(repo), {})
def test_get_projects_invalid_project_name(self): """Testing get_projects() with invalid project name""" repo = Repository('oss-fuzz', 'dir', 'projects', [ Repository('test0', 'dir', 'projects/test0', [ Repository('Dockerfile', 'file', 'projects/test0/Dockerfile') ]), Repository('test1@', 'dir', 'projects/test1', [ Repository('Dockerfile', 'file', 'projects/test1/Dockerfile') ]) ]) self.assertEqual(get_projects(repo), {'test0'})
def test_get_projects(self): """Testing get_projects().""" repo = Repository('oss-fuzz', 'dir', 'projects', [ Repository('test0', 'dir', 'projects/test0', [ Repository('Dockerfile', 'file', 'projects/test0/Dockerfile') ]), Repository('test1', 'dir', 'projects/test1', [ Repository('Dockerfile', 'file', 'projects/test1/Dockerfile') ]) ]) self.assertEqual(get_projects(repo), {'test0', 'test1'})
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') })
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') })