Renaming schedule variable to builds_per_day for new feature (#4091)

* Renaming schedule variable to builds_per_day for new feature

* Minor formatting change

Co-authored-by: Kabeer Seth <kabeerseth@google.com>
This commit is contained in:
kabeer27 2020-07-08 07:19:59 +00:00 committed by GitHub
parent 0a712bb5d4
commit 600c514958
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -146,15 +146,15 @@ def get_schedule(project_contents):
if content_file.name != 'project.yaml':
continue
project_yaml = yaml.safe_load(content_file.decoded_content.decode('utf-8'))
times_per_day = project_yaml.get('schedule', DEFAULT_BUILDS_PER_DAY)
if not isinstance(times_per_day, int) or times_per_day not in range(
builds_per_day = project_yaml.get('builds_per_day', DEFAULT_BUILDS_PER_DAY)
if not isinstance(builds_per_day, int) or builds_per_day not in range(
1, MAX_BUILDS_PER_DAY + 1):
raise ProjectYamlError('Parameter is not an integer in range [1-4]')
# Starting at 6:00 am, next build schedules are added at 'interval' slots
# Example for interval 2, hours = [6, 18] and schedule = '0 6,18 * * *'
interval = 24 // times_per_day
interval = 24 // builds_per_day
hours = []
for hour in range(6, 30, interval):
hours.append(hour % 24)

View File

@ -238,8 +238,8 @@ class TestDataSync(unittest.TestCase):
Repository('project.yaml', 'file', 'projects/test1/project.yaml')
])
])
repo.contents[0].contents[1].set_yaml_contents(b'schedule: 2')
repo.contents[1].contents[1].set_yaml_contents(b'schedule: 3')
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), {
@ -301,7 +301,8 @@ class TestDataSync(unittest.TestCase):
Repository('project.yaml', 'file', 'projects/test0/project.yaml')
])
])
repo.contents[0].contents[1].set_yaml_contents(b'schedule: some-string')
repo.contents[0].contents[1].set_yaml_contents(
b'builds_per_day: some-string')
self.assertEqual(get_projects(repo), {})
@ -314,7 +315,7 @@ class TestDataSync(unittest.TestCase):
Repository('project.yaml', 'file', 'projects/test0/project.yaml')
])
])
repo.contents[0].contents[1].set_yaml_contents(b'schedule: 5')
repo.contents[0].contents[1].set_yaml_contents(b'builds_per_day: 5')
self.assertEqual(get_projects(repo), {})