Ejemplo n.º 1
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})
Ejemplo n.º 2
0
  def test_sync_projects(self):
    """Testing sync_projects()."""
    client = ndb.Client()

    with client.context():
      Project(name='test1').put()
      Project(name='test2').put()

      projects = {'test1', 'test3'}
      sync_projects(projects)

      projects_query = Project.query()
      self.assertEqual(projects, {project.name for project in projects_query})
Ejemplo n.º 3
0
    def test_sync_projects_delete(self):
        """Testing sync_projects() deleting."""
        client = ndb.Client()
        cloud_scheduler_client = CloudSchedulerClient()

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

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

            projects_query = Project.query()
            self.assertEqual(
                {'test1': '0 8 * * *'},
                {project.name: project.schedule
                 for project in projects_query})