aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2019-10-31 07:39:03 +0100
committerGravatar Leon Sandøy <[email protected]>2019-10-31 07:39:03 +0100
commita98485e173208cc2272f5c6355ddaf5858050403 (patch)
treeb45f4dd1e87477c8c08e5e6dca5d6ae371d5d086
parentMerge branch 'duck_pond' of github.com:python-discord/bot into duck_pond (diff)
Figure out which tests we need.
This adds empty tests for all the tests I'd like to add to this pull request. It also adds a few more duckies to the emoji constant list, and adds a single line of clarification to the testing readme.
-rw-r--r--bot/constants.py8
-rw-r--r--tests/README.md1
-rw-r--r--tests/bot/cogs/test_duck_pond.py80
3 files changed, 87 insertions, 2 deletions
diff --git a/bot/constants.py b/bot/constants.py
index 79845711d..dbbf32063 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -261,8 +261,13 @@ class Emojis(metaclass=YAMLGetter):
pencil: str
cross_mark: str
- ducky: int
+ ducky_yellow: int
ducky_blurple: int
+ ducky_regal: int
+ ducky_camo: int
+ ducky_ninja: int
+ ducky_devil: int
+ ducky_tube: int
class Icons(metaclass=YAMLGetter):
@@ -341,7 +346,6 @@ class Channels(metaclass=YAMLGetter):
defcon: int
devlog: int
devtest: int
- duck_pond: int
help_0: int
help_1: int
help_2: int
diff --git a/tests/README.md b/tests/README.md
index 6ab9bc93e..d052de2f6 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -15,6 +15,7 @@ We are using the following modules and packages for our unit tests:
To ensure the results you obtain on your personal machine are comparable to those generated in the Azure pipeline, please make sure to run your tests with the virtual environment defined by our [Pipfile](/Pipfile). To run your tests with `pipenv`, we've provided two "scripts" shortcuts:
- `pipenv run test` will run `unittest` with `coverage.py`
+- `pipenv run test path/to/test.py` will run a specific test.
- `pipenv run report` will generate a coverage report of the tests you've run with `pipenv run test`. If you append the `-m` flag to this command, the report will include the lines and branches not covered by tests in addition to the test coverage report.
If you want a coverage report, make sure to run the tests with `pipenv run test` *first*.
diff --git a/tests/bot/cogs/test_duck_pond.py b/tests/bot/cogs/test_duck_pond.py
new file mode 100644
index 000000000..79f11843b
--- /dev/null
+++ b/tests/bot/cogs/test_duck_pond.py
@@ -0,0 +1,80 @@
+import logging
+import unittest
+from unittest.mock import MagicMock
+
+from bot.cogs import duck_pond
+from tests.helpers import MockBot, MockMessage
+
+
+class DuckPondTest(unittest.TestCase):
+ """Tests the `DuckPond` cog."""
+
+ def setUp(self):
+ """Adds the cog, a bot, and a message to the instance for usage in tests."""
+ self.bot = MockBot()
+ self.cog = duck_pond.DuckPond(bot=self.bot)
+
+ self.msg = MockMessage(message_id=555, content='')
+ self.msg.author.__str__ = MagicMock()
+ self.msg.author.__str__.return_value = 'lemon'
+ self.msg.author.bot = False
+ self.msg.author.avatar_url_as.return_value = 'picture-lemon.png'
+ self.msg.author.id = 42
+ self.msg.author.mention = '@lemon'
+ self.msg.channel.mention = "#lemonade-stand"
+
+ def test_is_staff_correctly_identifies_staff(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+ def test_has_green_checkmark(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+ def test_count_custom_duck_emojis(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+ def test_count_unicode_duck_emojis(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+ def test_count_mixed_duck_emojis(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+ def test_raw_reaction_add_rejects_bot(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+ def test_raw_reaction_add_rejects_non_staff(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+ def test_raw_reaction_add_sends_message_on_valid_input(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+ def test_raw_reaction_remove_rejects_non_checkmarks(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+ def test_raw_reaction_remove_prevents_checkmark_removal(self):
+ """A string decoding to numeric characters is a valid user ID."""
+ pass
+
+
+class DuckPondSetupTests(unittest.TestCase):
+ """Tests setup of the `DuckPond` cog."""
+
+ def test_setup(self):
+ """Setup of the cog should log a message at `INFO` level."""
+ bot = MockBot()
+ log = logging.getLogger('bot.cogs.duck_pond')
+
+ with self.assertLogs(logger=log, level=logging.INFO) as log_watcher:
+ duck_pond.setup(bot)
+ line = log_watcher.output[0]
+
+ bot.add_cog.assert_called_once()
+ self.assertIn("Cog loaded: DuckPond", line)