Ejemplo n.º 1
0
    def test_delete_many_started_builds(self):
        scheduled_build = test_util.build(id=1, status=common_pb2.SCHEDULED)
        started_build = test_util.build(id=2, status=common_pb2.STARTED)
        completed_build = test_util.build(id=3, status=common_pb2.SUCCESS)
        ndb.put_multi([scheduled_build, started_build, completed_build])

        service._task_delete_many_builds(scheduled_build.bucket_id,
                                         model.BuildStatus.STARTED)
        self.assertIsNotNone(scheduled_build.key.get())
        self.assertIsNone(started_build.key.get())
        self.assertIsNotNone(completed_build.key.get())
Ejemplo n.º 2
0
 def test_delete_many_scheduled_builds(self):
     scheduled_build = test_util.build(id=1, status=common_pb2.SCHEDULED)
     completed_build = test_util.build(id=2, status=common_pb2.SUCCESS)
     scheduled_build.put()
     completed_build.put()
     self.assertIsNotNone(scheduled_build.key.get())
     self.assertIsNotNone(completed_build.key.get())
     service._task_delete_many_builds(scheduled_build.bucket_id,
                                      model.BuildStatus.SCHEDULED)
     self.assertIsNone(scheduled_build.key.get())
     self.assertIsNotNone(completed_build.key.get())
Ejemplo n.º 3
0
  def test_delete_many_builds_created_by(self):
    self.test_build.created_by = auth.Identity('user', '*****@*****.**')
    self.test_build.put()
    other_build = model.Build(bucket=self.test_build.bucket)
    other_build.put()

    service._task_delete_many_builds(
      self.test_build.bucket, model.BuildStatus.SCHEDULED,
      created_by='*****@*****.**')
    self.assertIsNone(self.test_build.key.get())
    self.assertIsNotNone(other_build.key.get())
Ejemplo n.º 4
0
  def test_delete_many_builds_with_tags(self):
    self.test_build.tags = ['tag:1']
    self.test_build.put()

    service._task_delete_many_builds(
      self.test_build.bucket, model.BuildStatus.SCHEDULED, tags=['tag:0'])
    self.assertIsNotNone(self.test_build.key.get())

    service._task_delete_many_builds(
      self.test_build.bucket, model.BuildStatus.SCHEDULED, tags=['tag:1'])
    self.assertIsNone(self.test_build.key.get())
Ejemplo n.º 5
0
    def test_delete_many_builds_created_by(self):
        build1 = test_util.build(id=1, created_by='user:[email protected]')
        build2 = test_util.build(id=2, created_by='user:[email protected]')
        ndb.put_multi([build1, build2])

        service._task_delete_many_builds(
            build1.bucket_id,
            model.BuildStatus.SCHEDULED,
            created_by=build2.created_by,
        )
        self.assertIsNone(build2.key.get())
        self.assertIsNotNone(build1.key.get())
Ejemplo n.º 6
0
    def test_delete_many_builds_with_tags(self):
        build = test_util.build(tags=[dict(key='tag', value='1')])
        build.put()

        service._task_delete_many_builds(build.bucket_id,
                                         model.BuildStatus.SCHEDULED,
                                         tags=['tag:0'])
        self.assertIsNotNone(build.key.get())

        service._task_delete_many_builds(build.bucket_id,
                                         model.BuildStatus.SCHEDULED,
                                         tags=['tag:1'])
        self.assertIsNone(build.key.get())
Ejemplo n.º 7
0
    def test_delete_many_builds_created_by(self):
        bundle1 = test_util.build_bundle(id=1, created_by='user:[email protected]')
        bundle2 = test_util.build_bundle(id=2, created_by='user:[email protected]')
        bundle1.put()
        bundle2.put()

        service._task_delete_many_builds(
            bundle1.build.bucket_id,
            model.BuildStatus.SCHEDULED,
            created_by=bundle2.build.created_by,
        )
        self.assertIsNone(bundle2.build.key.get())
        self.assertIsNotNone(bundle1.build.key.get())
Ejemplo n.º 8
0
 def test_delete_many_scheduled_builds(self):
   self.test_build.put()
   completed_build = model.Build(
     bucket=self.test_build.bucket,
     status=model.BuildStatus.COMPLETED,
     result=model.BuildResult.SUCCESS,
   )
   completed_build.put()
   self.assertIsNotNone(self.test_build.key.get())
   self.assertIsNotNone(completed_build.key.get())
   service._task_delete_many_builds(
     self.test_build.bucket, model.BuildStatus.SCHEDULED)
   self.assertIsNone(self.test_build.key.get())
   self.assertIsNotNone(completed_build.key.get())