def test_sync_projects_update(self): """Testing sync_projects() updating a schedule.""" cloud_scheduler_client = CloudSchedulerClient() with ndb.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})
def test_sync_projects_create(self): """"Testing sync_projects() creating new schedule.""" cloud_scheduler_client = CloudSchedulerClient() with ndb.Client().context(): Project(name='test1', schedule='0 8 * * *', 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}) self.assertCountEqual([ { 'name': 'projects/test-project/location/us-central1/jobs/' 'test2-scheduler-fuzzing', 'pubsub_target': { 'topic_name': 'projects/test-project/topics/request-build', 'data': b'test2' }, 'schedule': '0 7 * * *' }, { 'name': 'projects/test-project/location/us-central1/jobs/' 'test2-scheduler-coverage', 'pubsub_target': { 'topic_name': 'projects/test-project/topics/request-coverage-build', 'data': b'test2' }, 'schedule': '0 6 * * *' }, ], cloud_scheduler_client.schedulers)