Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Unit Tests

Martin Nenseth edited this page May 23, 2017 · 5 revisions

External input

Testing functionality that either fully or partially relies on external inputs (users) that does not explicitly return is not possible without mocking both the inputs, and the environment for the inputs. Our soloution is to refactor* functions like these. *replacing bot.say("x") with return statements.

Environment

The environment for testing these functions is set up in the same manner as the original code, defining and checking if the calling user is an owner, and whether the command is valid or not.

The implementation of the refactored functions can be found in commandsRefactored.py, while the unit tests themselves, can be found in commandsUnitTests.py

Database

The setUp() function clears the relevant table, to avoid conflicts while testing. Then the function inserts a row in the into the table restricted games which will be used in the actual unit test. The actual test simply compares the value inserted in setUp(), with a specified game title.

The implemenation of the unit tests for the database functions, can be found in dbUnitTests.py

Currently this file contains extensive unittests for flag_gaming_channel, flagged_games, and test_get_rich_users.

Clone this wiki locally