From 02bd10adcb105444801703ccdcff3c3d120f4989 Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Thu, 1 Jul 2021 01:16:52 +0200 Subject: [PATCH] Additional snipe tests --- tests/test_data/test_snipe.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/test_data/test_snipe.py diff --git a/tests/test_data/test_snipe.py b/tests/test_data/test_snipe.py new file mode 100644 index 0000000..400d044 --- /dev/null +++ b/tests/test_data/test_snipe.py @@ -0,0 +1,27 @@ +from data.snipe import should_snipe +import unittest +from unittest.mock import Mock + + +class TestSnipe(unittest.TestCase): + def test_should_snipe(self): + mock_message = Mock() + mock_guild = Mock() + mock_author = Mock() + + # Guild is None + mock_message.guild = None + self.assertFalse(should_snipe(mock_message)) + mock_message.guild = mock_guild + + # Author is a bot + mock_message.author = mock_author + mock_author.bot = True + self.assertFalse(should_snipe(mock_message)) + mock_author.bot = False + + mock_message.content = "Some string that contains A123B-CE68S-Z6B34 a Steam code" + self.assertFalse(should_snipe(mock_message)) + + mock_message.content = "Some string that does NOT contain a Steam code" + self.assertTrue(should_snipe(mock_message))