def delete_cart(self, env, start_response): """Delete a cart that has been created""" resp = cart_interface_responses.Responses() uid = fix_cart_uid(env['PATH_INFO']) is_valid = is_valid_uid(uid) if not is_valid: self._response = resp.invalid_uid_error_response( start_response, uid) return self.return_response() cart_utils = Cartutils() message = cart_utils.remove_cart(uid) if message is False: self._response = resp.cart_not_found(start_response) else: self._response = resp.cart_delete_response(start_response, message) return self.return_response()
def test_bad_stage(self, mock_delete_cart): """test the bad stage of a archive file""" with test_database(SqliteDatabase(':memory:'), (Cart, File)): test_cart = Cart.create(cart_uid='1', status='staging') def fake_database_connect(cls_name): """no error""" return cls_name def fake_database_close(cls_name): """no error""" return cls_name cart.cart_orm.CartBase.database_connect = MethodType( fake_database_connect, cart.cart_orm.CartBase) cart.cart_orm.CartBase.database_close = MethodType( fake_database_close, cart.cart_orm.CartBase) cart.cart_orm.CartBase.throw_error = False mock_delete_cart.return_value = False cart_util = Cartutils() return_val = cart_util.remove_cart(test_cart.id) self.assertEqual(return_val, None)