Skip to content

Commit

Permalink
fix test cases for ascii_cog.py
Browse files Browse the repository at this point in the history
  • Loading branch information
minimike86 committed Nov 5, 2024
1 parent b8a56e1 commit 0a1c447
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 3 deletions.
160 changes: 160 additions & 0 deletions tests/cogs/test_ascii_cog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import pytest

from twitchrce import custom_bot
from twitchrce.cogs.ascii_cog import AsciiCog


@pytest.fixture
def mock_bot(mocker):
mock_bot: custom_bot.CustomBot = mocker.Mock()
mock_bot._checks = []
return mock_bot


@pytest.fixture
def mock_ctx(mocker, mock_bot):
mock_ctx = mocker.Mock()
mock_ctx.bot = mock_bot
mock_ctx.author = mocker.Mock()
mock_ctx.author.name = "author_name"
mock_ctx.channel = mocker.Mock()
mock_ctx.channel.name = "channel_name"
mock_ctx.channel.channel.name = "channel_name"
mock_ctx.channel.__messageable_channel__ = True
mock_ctx.send = mocker.AsyncMock()
return mock_ctx


@pytest.mark.asyncio
async def test_kill_everyone(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.kill_everyone(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_mario(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.mario(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_spider(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.spider(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_spider_swarm(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.spider_swarm(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_deez(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.deez(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_secplus(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.secplus(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_letsgo(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.letsgo(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_capybara(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.capybara(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_weeb1(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.weeb1(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_weeb2(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.weeb2(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_shark(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.shark(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_gotem(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.gotem(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_fuchat(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.fuchat(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_creeper(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.creeper(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")


@pytest.mark.asyncio
async def test_timehascome(mock_bot, mock_ctx):
ascii_cog = AsciiCog(bot=mock_bot)
try:
await ascii_cog.timehascome(mock_ctx)
except Exception as error:
pytest.fail(f"Raised an exception: {error}")
15 changes: 12 additions & 3 deletions twitchrce/cogs/ascii_cog.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import logging

import twitchio
from twitchio.ext import commands

from twitchrce import custom_bot

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s | %(levelname)-8s | %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
logger = logging.getLogger(__name__)


class AsciiCog(commands.Cog):

def __init__(self, bot: custom_bot.CustomBot):
self.bot = bot

@commands.Cog.event()
async def event_message(self, message: twitchio.Message):
async def event_message(self, message: twitchio.Message): # pragma: no cover
if message.echo:
return
# print('RCECog: ', message.author.name, message.content)
logger.info('[RCECog]: ', message.author.name, message.content)

@commands.command()
async def kill_everyone(self, ctx: commands.Context):
Expand Down Expand Up @@ -49,7 +58,7 @@ async def spider(self, ctx: commands.Context):
)

@commands.command()
async def spiderswarm(self, ctx: commands.Context):
async def spider_swarm(self, ctx: commands.Context):
await ctx.send(
f"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ "
f"╱╲⎝⧹༼◕ ͜ﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞﱞo.◕ ༽⧸⎠╱╲"
Expand Down

0 comments on commit 0a1c447

Please sign in to comment.