Exemple #1
0
    def test_cleanup_soft_deletion_date(self, project):
        """Test cleaning up entries within date"""
        secret = _setup_entry('secret', project=project)
        order = order = _setup_entry('order', project=project, secret=secret)
        current_time = datetime.datetime.utcnow()
        tomorrow = current_time + datetime.timedelta(days=1)
        yesterday = current_time - datetime.timedelta(days=1)
        secret.delete()
        order.delete()

        # Assert that nothing is deleted due to date
        clean.cleanup_softdeletes(models.Order, threshold_date=yesterday)
        clean.cleanup_parent_with_no_child(models.Secret,
                                           models.Order,
                                           threshold_date=yesterday)
        self.assertTrue(_entry_exists(secret))
        self.assertTrue(_entry_exists(order))

        # Assert that everything is deleted due to date
        clean.cleanup_softdeletes(models.Order, threshold_date=tomorrow)
        clean.cleanup_parent_with_no_child(models.Secret,
                                           models.Order,
                                           threshold_date=tomorrow)
        self.assertFalse(_entry_exists(secret))
        self.assertFalse(_entry_exists(order))
    def test_soft_deleted_secret_orders(self, project):
        """Test that secrets without child order get deleted"""
        # Create a secret tied to an order and one secret that is not
        secret1 = _setup_entry('secret', project=project)
        secret2 = _setup_entry('secret', project=project)
        order = _setup_entry('order', project=project, secret=secret1)

        # Delete secrets
        secret1.delete()
        secret2.delete()
        clean.cleanup_parent_with_no_child(models.Secret, models.Order)

        # Assert that only secret2 is removed
        self.assertTrue(_entry_exists(secret1))
        self.assertFalse(_entry_exists(secret2))

        # delete order and secret
        order.delete()
        clean.cleanup_all()

        self.assertFalse(_entry_exists(order))
        self.assertFalse(_entry_exists(secret2))
Exemple #3
0
    def test_soft_deleted_secret_orders(self, project):
        """Test that secrets without child order get deleted"""
        # Create a secret tied to an order and one secret that is not
        secret1 = _setup_entry('secret', project=project)
        secret2 = _setup_entry('secret', project=project)
        order = _setup_entry('order', project=project, secret=secret1)

        # Delete secrets
        secret1.delete()
        secret2.delete()
        clean.cleanup_parent_with_no_child(models.Secret, models.Order)

        # Assert that only secret2 is removed
        self.assertTrue(_entry_exists(secret1))
        self.assertFalse(_entry_exists(secret2))

        # delete order and secret
        order.delete()
        clean.cleanup_all()

        self.assertFalse(_entry_exists(order))
        self.assertFalse(_entry_exists(secret2))
    def test_cleanup_soft_deletion_date(self, project):
        """Test cleaning up entries within date"""
        secret = _setup_entry('secret', project=project)
        order = order = _setup_entry('order', project=project, secret=secret)
        current_time = datetime.datetime.utcnow()
        tomorrow = current_time + datetime.timedelta(days=1)
        yesterday = current_time - datetime.timedelta(days=1)
        secret.delete()
        order.delete()

        # Assert that nothing is deleted due to date
        clean.cleanup_softdeletes(models.Order, threshold_date=yesterday)
        clean.cleanup_parent_with_no_child(models.Secret, models.Order,
                                           threshold_date=yesterday)
        self.assertTrue(_entry_exists(secret))
        self.assertTrue(_entry_exists(order))

        # Assert that everything is deleted due to date
        clean.cleanup_softdeletes(models.Order, threshold_date=tomorrow)
        clean.cleanup_parent_with_no_child(models.Secret, models.Order,
                                           threshold_date=tomorrow)
        self.assertFalse(_entry_exists(secret))
        self.assertFalse(_entry_exists(order))