From 600c51495857ff9d20d6cf683df6504b69a0f2a2 Mon Sep 17 00:00:00 2001 From: kabeer27 <32016558+kabeer27@users.noreply.github.com> Date: Wed, 8 Jul 2020 07:19:59 +0000 Subject: 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 --- infra/build/functions/sync/main.py | 6 +++--- infra/build/functions/sync/main_test.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'infra/build') diff --git a/infra/build/functions/sync/main.py b/infra/build/functions/sync/main.py index ad57910d6..3fea68b09 100644 --- a/infra/build/functions/sync/main.py +++ b/infra/build/functions/sync/main.py @@ -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) diff --git a/infra/build/functions/sync/main_test.py b/infra/build/functions/sync/main_test.py index f49ea10e8..b52a8a0c1 100644 --- a/infra/build/functions/sync/main_test.py +++ b/infra/build/functions/sync/main_test.py @@ -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), {}) -- cgit v1.2.3