aboutsummaryrefslogtreecommitdiffstats
path: root/tests (follow)
Commit message (Collapse)AuthorAgeLines
* Add test cases for in_channel_checkGravatar Atul Mishra2019-10-22-0/+8
|
* Merge branch 'master' into moderator-channel-checkGravatar Atul Mishra2019-10-22-1174/+2310
|\
| * Merge branch 'master' into unittest-migrationGravatar Sebastiaan Zeeff2019-10-15-0/+62
| |\ | | | | | | | | | | | | Resolving merge conflicts from master in `.gitignore` and `tests/helpers.py`.
| * | Remove empty tests.cogs folderGravatar Sebastiaan Zeeff2019-10-14-0/+0
| | |
| * | Make test_token_remover use our discord MocksGravatar Sebastiaan Zeeff2019-10-14-8/+5
| | | | | | | | | | | | | | | | | | | | | This commit replaces the standard MagicMocks by our specialized mocks for discord.py objects. It also adds the missing `channel` attribute to the `tests.helpers.MockMessage` mock and moves the file to the correct folder.
| * | Use `MockBot`.Gravatar Johannes Christ2019-10-14-3/+3
| | |
| * | Move the `token_remover` cog tests to `unittest`.Gravatar Johannes Christ2019-10-14-0/+139
| | |
| * | Merge branch 'unittest-migration' of github.com:python-discord/bot into ↵Gravatar Sebastiaan Zeeff2019-10-14-0/+26
| |\ \ | | | | | | | | | | | | unittest-migration
| | * | Migrate test_constants to unittestGravatar Sebastiaan Zeeff2019-10-14-0/+26
| | | | | | | | | | | | | | | | | | | | Migrates the `test_constants.py` file to unittest. As with the pytest version, there is not yet support to test container types.
| * | | Add more specialized Mocks to tests.helpersGravatar Sebastiaan Zeeff2019-10-14-181/+383
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces some new Mock-types to the already existing Mock-types for discord.py objects. The total list is now: - MockGuild - MockRole - MockMember - MockBot - MockContext - MockTextChannel - MockMessage In addition, I've added all coroutines in the documentation for these discord.py objects as `AsyncMock` attributes to ease testing. Tests ensure that the attributes set for the Mocks exist for the actual discord.py objects as well.
| * | Remove empty tests.cogs folderGravatar Sebastiaan Zeeff2019-10-14-0/+0
| | |
| * | Merge branch 'cogs-security-unittest' into unittest-migrationGravatar Sebastiaan Zeeff2019-10-14-0/+59
| |\ \
| | * | Move test_security to tests.bot.cogsGravatar Sebastiaan Zeeff2019-10-14-0/+0
| | | |
| | * | Use `MockBot` and `MockContext`.Gravatar Johannes Christ2019-10-13-3/+3
| | | |
| | * | Move the `security` cog tests to `unittest`.Gravatar Johannes Christ2019-10-12-0/+59
| | | |
| * | | Merge branch 'pagination-tests-to-unittest' into unittest-migrationGravatar Sebastiaan Zeeff2019-10-14-0/+36
| |\ \ \
| | * | | Move test_pagination to tests.bot subdirGravatar Sebastiaan Zeeff2019-10-14-0/+0
| | | | |
| | * | | Move `tests.test_pagination` to `unittest`.Gravatar Johannes Christ2019-10-12-0/+36
| | |/ /
| * | | Move sync tests to tests.bot.cogs.syncGravatar Sebastiaan Zeeff2019-10-13-0/+0
| | | |
| * | | Merge branch 'cogs-antispam-unittest' into unittest-migrationGravatar Sebastiaan Zeeff2019-10-13-0/+35
| |\ \ \
| | * | | Move test_antispam.py to tests.bot.cogsGravatar Sebastiaan Zeeff2019-10-13-0/+0
| | | | |
| | * | | Move the `antispam` cog tests to `unittest`.Gravatar Johannes Christ2019-10-12-0/+35
| | |/ /
| * | | Merge branch 'rules-attachment-tests-unittest' into unittest-migrationGravatar Sebastiaan Zeeff2019-10-13-0/+52
| |\ \ \
| | * | | Move test_attachments.py to tests/bot/rules dirGravatar Sebastiaan Zeeff2019-10-13-0/+0
| | | | |
| | * | | Move the `rules.attachments` module tests to `unittest`.Gravatar Johannes Christ2019-10-12-0/+52
| | |/ /
| * | | Merge branch 'resources-to-unittest' into unittest-migrationGravatar Sebastiaan Zeeff2019-10-13-0/+17
| |\ \ \
| | * | | Add subTest + move test_resource to resources subdirGravatar Sebastiaan Zeeff2019-10-13-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've added a `self.subTest` to the `name` loop so we still test and get output for all names in the list if one of them fails the test. In addition, I've moved it to the `tests/bot/resources` subdirectory.
| | * | | Move `tests.test_resources` to `unittest`.Gravatar Johannes Christ2019-10-12-0/+16
| | |/ /
| * / / Move the `sync` cog tests to `unittest`.Gravatar Johannes Christ2019-10-12-0/+210
| |/ /
| * | Update README.mdGravatar Sebastiaan Zeeff2019-10-11-8/+7
| | |
| * | Make textual changes to testing guideGravatar Sebastiaan Zeeff2019-10-11-20/+34
| | | | | | | | | | | | | | | I've made some textual changes to the testing guidelines defined in README.md.
| * | Change pipeline testrunner to xmlrunnerGravatar Sebastiaan Zeeff2019-10-11-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | I have change the testrunner from `unittest` to `xmlrunner` in the Azure pipeline to be able to publish our test results on Azure. This is the same runner as `site` uses to generate XML reports. In addition, I've cleaned up some small mistakes in docstrings and `README.md`.
| * | Add tests for tests.baseGravatar Sebastiaan Zeeff2019-10-11-4/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I forgot to test some aspects of the `tests.base` module, including some branches of the `self.assertNotLogs` method. I've corrected that by including a couple of tests. I also removed the test result publishing from the Azure pipeline, since I've not configured an XML test runner yet. The coverage report is still published, of course and test output will be available in standard out, so information is readily available.
| * | Migrate pytest to unittestGravatar Sebastiaan Zeeff2019-10-11-1196/+1525
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a discussion in the core developers channel, we have decided to migrate from `pytest` to `unittest` as the testing framework. This commit sets up the repository to use `unittest` and migrates the first couple of tests files to the new framework. What I have done to migrate to `unitest`: - Removed all `pytest` test files, since they are incompatible. - Removed `pytest`-related dependencies from the Pipfile. - Added `coverage.py` to the Pipfile dev-packages and relocked. - Added convenience scripts to Pipfile for running the test suite. - Adjust to `azure-pipelines.yml` to use `coverage.py` and `unittest`. - Migrated four test files from `pytest` to `unittest` format. In addition, I've added five helper Mock subclasses in `helpers.py` and created a `TestCase` subclass in `base.py` to add an assertion that asserts that no log records were logged within the context of the context manager. Obviously, these new utility functions and classes are fully tested in their respective `test_` files. Finally, I've started with an introductory guide for writing tests for our bot in `README.md`.
* | | Modify in_channel_check to accept list of channelsGravatar Atul Mishra2019-10-22-4/+4
| |/ |/| | | | | - Update test cases for in_channel_check
* | Raise `ValueError` on negative `max_units`.Gravatar Johannes Christ2019-10-12-3/+6
| |
* | Merge branch 'master' into bot-utils-time-testsGravatar Johannes Christ2019-10-11-23/+237
|\|
| * Merge branch 'master' into moderation-cleanupGravatar Sebastiaan Zeeff2019-10-08-0/+126
| |\
| | * Merge branch 'master' into add-role-info-commandGravatar Chris G2019-10-04-0/+78
| | |\
| | | * Check if tzinfo is None in ISODateTime testGravatar Sebastiaan Zeeff2019-10-03-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As we have decided that the converter should return naive datetime objects, we should explicitly test that datetime strings with a timezone offset are still converted to a naive datetime object. I have done this by adding a `tzinfo is None` assertion.
| | | * Make ISODateTime return tz-unaware datetimeGravatar Sebastiaan Zeeff2019-10-02-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The parser we use, `dateutil.parsers.isoparse` returns a timezone- aware or timezone-unaware `datetime` object depending on whether or not the datetime string included a timezone offset specification. Since we can't compare tz-aware objects to tz-unaware objects it's better to make sure our converter is consistent in the type it will return. For now, I've chosen to return tz-unaware datetime objects, since `discord.py` also returns tz-unaware datetime objects when accessing datetime-related attributes of objects. Since we're likely to compare "our" datetime objects to discord.py-provided datetime objects, I think that's the most parsimonious option for now. Note: It's probably a good idea to open a larger discussion about using timezone-aware datetime objects throughout the library to avoid a UTC-time being interpreted as localtime. This will require a broader discussion than this commit/PR allows, though.
| | | * Apply docstring review suggestionGravatar Sebastiaan Zeeff2019-10-02-1/+1
| | | | | | | | | | | | Co-Authored-By: Mark <[email protected]>
| | | * Add converter for ISO-formatted datetime stringsGravatar Sebastiaan Zeeff2019-10-01-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related to https://github.com/python-discord/bot/issues/458 This commit adds a converter that automatically parses ISO-formatted datetime strings and returns a `datetime.datetime` object. It uses `dateutil.parser.isoparse` to do the heavy lifting, so it supports the same formats as this method. In addition, I have added tests that ensure that it accepts certain formats and added a description of these 'guaranteed' formats to the `ISODate.convert` docstring. This commit should make it easy to implement #485
| | * | Merge branch 'add-role-info-command' of github.com:python-discord/bot into ↵Gravatar Joseph Banks2019-10-01-15/+108
| | |\ \ | | | | | | | | | | | | | | | add-role-info-command
| | | * | Merge branch 'master' into add-role-info-commandGravatar S. Co12019-10-01-15/+108
| | | |\|
| | * | | Make tests work with Union converterGravatar Joseph Banks2019-10-01-3/+4
| | |/ /
| | * | Add unit tests for role info commandGravatar Joseph Banks2019-09-21-0/+47
| | | |
| * | | Fix stars.json resource testGravatar MarkKoz2019-10-01-8/+3
| | |/ | |/|
| * | Allow whitespace in duration strings and update testsGravatar Sebastiaan Zeeff2019-09-23-47/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://github.com/python-discord/bot/issues/446 After review feedback and a discussion in the dev-core team, I've changed a couple of things: - Allow a space between amount and unit in the duration string; - Allow a space between different units in the duration string; - Remove the old ExpirationDate converter completely; - Remove the dependency `dateparser` from the Pipfile; - Update tests for the two types of optional spaces; - Change the test for valid cases to a more readable format; This PR closes #446
| * | Fix failing duration conversionGravatar Sebastiaan Zeeff2019-09-23-4/+78
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://github.com/python-discord/bot/issues/446 The current ExpirationDate converter does not convert duration strings to `datetime.datetime` objects correctly. To remedy the problem, I've written a new Duration converter that uses regex matching to extract the relevant duration units and `dateutil.relativedelta.relativedelta` to compute a `datetime.datetime` that's the given duration in the future. I've left the old `ExpirationDate` converter in place for now, since the new Duration converter may not be the most optimal method. However, given the importance of being able to convert durations for moderation tasks, I think it's better to implement Duration now and rethink the approach later. This commit closes #446