def test_createItem_success(self): item1 = ItemUtil.createItem(guild_id=1, item_name="hello", item_type=ItemType.ATTACK, buff_type=1, buff_value=-1, buff_round=2) result = ItemUtil.ListAllItem(guild_id=1) assert len(result) == 1 and result[0] == item1
def test_deleteItem_success(self): ItemUtil.createItem(guild_id=1, item_name="hello", item_type=ItemType.ATTACK, buff_type=1, buff_value=-1, buff_round=2, level_required=0, price=1) ItemUtil.deleteItem(guild_id=1, item_name="hello") result = ItemUtil.ListAllItem(guild_id=1) assert result == []
def test_buffTypeStorageRead_success(self): item = ItemUtil.createItem(guild_id=1, item_name="hello", item_type=ItemType.ATTACK, buff_type=BuffType.ATTACK, buff_value=30, buff_round=3) item_from_db = ItemUtil.ListAllItem(guild_id=1)[0] item_buff: Buff = item_from_db.buff assert item_buff.buff_type == BuffType.ATTACK assert item_buff.buff_value == 30 assert item_buff.buff_round == 3
async def list_item(self, ctx: commands.Command): result = ItemUtil.ListAllItem(ctx.guild.id) if len(result) < 1: await ctx.send('目前沒有商品') else: msg = "```" for products in result: msg += " 購買ID: {}".format(str(products.id).ljust(3, " ")) msg += " 商品名稱: {}".format(products.name).ljust(15, " ") msg += " 等級限制: {}".format( str(products.level_required).ljust(3, " ")) msg += " 價格: {}\n".format( str(products.token_required).ljust(3, " ")) msg += "```" await ctx.send(msg)
def test_addItemToItemdb_failed_samename(self): ItemUtil.createItem(guild_id=1, item_name="hello", item_type=ItemType.ATTACK, buff_type=BuffType.ATTACK, buff_value=-1, buff_round=2) item2 = ItemUtil.createItem(guild_id=1, item_name="hello", item_type=ItemType.ATTACK, buff_type=BuffType.ATTACK, buff_value=-1, buff_round=2) items = ItemUtil.ListAllItem(guild_id=1) assert len(items) == 1 and item2 == -1
def test_addItemToItemdb_success(self): item1 = ItemUtil.createItem(guild_id=1, item_name="hello", item_type=ItemType.ATTACK, buff_type=BuffType.ATTACK, buff_value=-1, buff_round=2) item2 = ItemUtil.createItem(guild_id=1, item_name="hey", item_type=ItemType.STATUS, buff_type=BuffType.DEFENCE, buff_value=10, buff_round=3) items = ItemUtil.ListAllItem(guild_id=1) assert items == [item1, item2]
def test_deleteItem_failed_noItem(self): ItemUtil.deleteItem(guild_id=1, item_name="hello") result = ItemUtil.ListAllItem(guild_id=1) assert result == []
def test_deleteItems_failed_noItem(self): ItemUtil.deleteItems(guild_id=1) result = ItemUtil.ListAllItem(guild_id=1) assert result == []