def test_listHiddenitem_success(self):
        result = InventoryUtil.listHiddenShopItem(guild_id=1)
        assert len(result) == 0

        ItemUtil.createItem(guild_id=1,
                            item_name="hello",
                            item_type=ItemType.ATTACK,
                            buff_type=BuffType.ATTACK,
                            buff_value=-1,
                            buff_round=2,
                            level_required=0,
                            price=1)
        ItemUtil.createItem(guild_id=1,
                            item_name="hey",
                            item_type=ItemType.STATUS,
                            buff_type=BuffType.DEFENCE,
                            buff_value=10,
                            buff_round=3,
                            level_required=0,
                            price=1)
        InventoryUtil.addItemToShop(guild_id=1, item_name="hello", amount=10)
        InventoryUtil.addItemToShop(guild_id=1, item_name="hey", amount=10)
        InventoryUtil.changeShopitemHiddenStatus(guild_id=1,
                                                 item_name="hello",
                                                 hidden=True)
        result = InventoryUtil.listHiddenShopItem(guild_id=1)
        assert len(result) == 1

        # items
        InventoryUtil.changeShopitemHiddenStatus(guild_id=1,
                                                 item_name="hey",
                                                 hidden=True)
        result = InventoryUtil.listHiddenShopItem(guild_id=1)
        assert len(result) == 2
 def test_changeShopitemHiddenStatus_success(self):
     ItemUtil.createItem(guild_id=1,
                         item_name="hello",
                         item_type=ItemType.ATTACK,
                         buff_type=BuffType.ATTACK,
                         buff_value=-1,
                         buff_round=2,
                         level_required=0,
                         price=10)
     InventoryUtil.addItemToShop(guild_id=1, item_name="hello", amount=10)
     result = InventoryUtil.changeShopitemHiddenStatus(guild_id=1,
                                                       item_name="hello",
                                                       hidden=True)
     assert result.hidden == True
     result2 = InventoryUtil.ShopMenu(guild_id=1)
     assert len(result2) == 0
     result3 = InventoryUtil.changeShopitemHiddenStatus(guild_id=1,
                                                        item_name="hello",
                                                        hidden=False)
     assert result3.hidden == False
示例#3
0
 async def change_shopitemHidden_status(self, ctx: commands.Command,
                                        item_name: str, hidden: bool):
     result = InventoryUtil.changeShopitemHiddenStatus(
         ctx.guild.id, item_name, hidden)
     if result == -1:
         await ctx.send("查無此項目,請確認商品名稱是否輸入錯誤!")
     elif result == -2:
         await ctx.send("該商品存在但尚未上架!")
     else:
         if hidden == True:
             await ctx.send(f"修改成功! 目前{item_name}狀態改為隱藏")
         else:
             await ctx.send(f"修改成功! 目前{item_name}供給數量為{result.amount}")
 def test_changeShopitemHiddenStatus_failed_noitem(self):
     ItemUtil.createItem(guild_id=1,
                         item_name="hello",
                         item_type=ItemType.ATTACK,
                         buff_type=BuffType.ATTACK,
                         buff_value=-1,
                         buff_round=2,
                         level_required=0,
                         price=10)
     InventoryUtil.addItemToShop(guild_id=1, item_name="hello", amount=10)
     result = InventoryUtil.changeShopitemHiddenStatus(guild_id=1,
                                                       item_name="he",
                                                       hidden=True)
     assert result == -1