def test_full(self): """ Test that a project with a started slice can be deleted. """ start_test_slice(self) slice_name = "%s" % self.slice self.client.login( username=self.u2.username, password="******") threadlocals.push_frame(user=self.u2) # delete the project. This should delete all the slivers # and resources, and delete the slice. It should also stop # the slice (which creates a DummySliceEvent) response = test_get_and_post_form( client=self.client, url=self.project.get_delete_url(), params={}, ) self.assertRedirects(response, "/") self.assertEqual( DummySliceEvent.objects.filter( slice=slice_name, status="stopped").count(), 2) self.assertEqual(Sliver.objects.count(), 0) self.assertEqual(Project.objects.count(), 0) self.client.logout() threadlocals.pop_frame()
def test_slice_expiration(self): """ Check that a slice expires correctly. """ start_test_slice(self) self.slice.expiration_date = datetime.now() - timedelta(days=1) self.slice.save() slice_name = "%s" % self.slice self.assertTrue(self.slice.started) for j in Job.objects.all(): j.next_run_time = datetime.now() j.save() call_command("run_timer_jobs") self.slice = Slice.objects.get(pk=self.slice.pk) self.assertFalse(self.slice.started) self.assertEqual( DummySliceEvent.objects.filter( slice=slice_name, status="stopped", aggregate="%s" % self.agg1, ).count(), 1, ) self.assertEqual( DummySliceEvent.objects.filter( slice=slice_name, status="stopped", aggregate="%s" % self.agg2, ).count(), 1, )
def test_allowed_delete_with_started_slice(self): ''' Tests that we can delete an aggregate that is in a started slice. ''' start_test_slice(self) self.client.login(username=self.u1.username, password="******") threadlocals.push_frame(user=self.u1) # delete the aggregate. This should delete all the slivers # and resources, and create a DummySliceEvent to that effect. response = test_get_and_post_form( client=self.client, url=self.agg1.get_delete_url(next="/"), params={}, ) self.assertRedirects(response, "/") self.assertEqual(DummyAggregate.objects.count(), 1) self.assertEqual(Sliver.objects.count(), 3) self.assertEqual( DummySliceEvent.objects.filter(slice="%s" % self.slice, status="stopped").count(), 1)
def test_allowed_delete_with_started_slice(self): ''' Tests that we can delete an aggregate that is in a started slice. ''' start_test_slice(self) self.client.login(username=self.u1.username, password="******") threadlocals.push_frame(user=self.u1) # delete the aggregate. This should delete all the slivers # and resources, and create a DummySliceEvent to that effect. response = test_get_and_post_form( client=self.client, url=self.agg1.get_delete_url(next="/"), params={}, ) self.assertRedirects(response, "/") self.assertEqual(DummyAggregate.objects.count(), 1) self.assertEqual(Sliver.objects.count(), 3) self.assertEqual( DummySliceEvent.objects.filter( slice="%s" % self.slice, status="stopped").count(), 1)