From d92f2a3e39c6605076c413e0c765ca7ca94217cd Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Tue, 26 Mar 2024 22:52:49 +0000 Subject: [PATCH 1/2] Add additional unit tests --- tests/test_img.py | 2 +- tests/test_meme.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/test_meme.py diff --git a/tests/test_img.py b/tests/test_img.py index 82ba566..95d8b60 100644 --- a/tests/test_img.py +++ b/tests/test_img.py @@ -2,7 +2,7 @@ """Provides test cases for webexmemebot/img.py.""" -import pytest +import pytest # pragma: no cover from app import img # pragma: no cover diff --git a/tests/test_meme.py b/tests/test_meme.py new file mode 100644 index 0000000..56940cc --- /dev/null +++ b/tests/test_meme.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +"""Provides test cases for webexmemebot/img.py.""" + +import pytest # pragma: no cover + +from webex_bot.models.response import Response # pragma: no cover + +from app import meme # pragma: no cover + + +def test_adaptive_card_create() -> None: + """Test to ensure that the adaptive card is created.""" + command = meme.MakeMemeCommand() + result = command.execute(None, None, None) + assert isinstance(result, Response) + + +def test_error_true() -> None: + """Test to ensure that execute() exits when error=True.""" + callback = meme.MakeMemeCallback() + callback.error = True + result = callback.execute(None, None, None) + assert result is None + + +def test_error_false() -> None: + """Test to ensure that execute() completes when error=False.""" + callback = meme.MakeMemeCallback() + callback.meme = "oprah.png" + callback.text_top = "TEST" + callback.text_bottom = "TEST" + result: Response = callback.execute(None, None, {"target": {"globalId": "TEST"}}) + assert ( + isinstance(result, Response) \ + and result.roomId == "TEST" \ + and result.files[0] == callback.meme_filename + ) -- 2.45.2 From f1229ce8bcd188bb93b011a0c9552ef3c7137a60 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Tue, 26 Mar 2024 22:56:32 +0000 Subject: [PATCH 2/2] remove unused import --- tests/test_meme.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_meme.py b/tests/test_meme.py index 56940cc..20479f2 100644 --- a/tests/test_meme.py +++ b/tests/test_meme.py @@ -2,8 +2,6 @@ """Provides test cases for webexmemebot/img.py.""" -import pytest # pragma: no cover - from webex_bot.models.response import Response # pragma: no cover from app import meme # pragma: no cover -- 2.45.2