def test_delete_cart_bundle(self):
        """test that trys to delete a cart bundle"""
        with test_database(SqliteDatabase(':memory:'), (Cart, File)):

            test_cart = Cart.create(cart_uid='1', status="staging",
                                    bundle_path="/tmp/1/")
            cart_utils = Cartutils()
            os.makedirs(test_cart.bundle_path, 0777)
            deleted = cart_utils.delete_cart_bundle(test_cart)
            self.assertEqual(test_cart.status, "deleted")
            self.assertEqual(deleted, True)
            self.assertEqual(os.path.isdir(test_cart.bundle_path), False)
    def test_delete_cart_bundle(self):
        """test that trys to delete a cart bundle"""
        with test_database(SqliteDatabase(':memory:'), (Cart, File)):

            test_cart = Cart.create(cart_uid='1',
                                    status='staging',
                                    bundle_path='/tmp/1/')
            cart_utils = Cartutils()
            os.makedirs(test_cart.bundle_path, 0o777)
            deleted = cart_utils.delete_cart_bundle(test_cart)
            self.assertEqual(test_cart.status, 'deleted')
            self.assertEqual(deleted, True)
            self.assertEqual(os.path.isdir(test_cart.bundle_path), False)
    def test_delete_cart_bundle_fail(self, mock_rmtree):
        """test that trys to delete a cart bundle but fails"""
        with test_database(SqliteDatabase(':memory:'), (Cart, File)):

            test_cart = Cart.create(cart_uid='1',
                                    status='staging',
                                    bundle_path='/tmp/1/')
            cart_utils = Cartutils()
            os.makedirs(test_cart.bundle_path, 0o777)
            mock_rmtree.side_effect = OSError(mock.Mock(), 'Error')
            deleted = cart_utils.delete_cart_bundle(test_cart)
            self.assertNotEqual(test_cart.status, 'deleted')
            self.assertEqual(deleted, False)
            self.assertEqual(os.path.isdir(test_cart.bundle_path), True)