Closed EliAndrewC closed 10 years ago
The first one is covered by a built in py.test fixture called capsys
On Mon, Mar 24, 2014 at 6:41 PM, Eli Courtwright notifications@github.com wrote:
The {{sideboard.tests}} module has a lot of utilities it provides in the form of two main base classes ({{SideboardTest}} and {{SideboardServerTest}}) which can be extended to get all the nice test methods. However, it looks like we're definitely using pytest from now on, so we should pytest-ify these features. At first we'll need to keep the old ways around for backwards compatibility, and eventually we can get rid of them when no one is using them anymore. At a glance, we need utility functions and pytest fixtures for doing the following things (this is not necessarily an exhaustive list):
- making assertions about log messages
- overriding services
- waiting for things to happen
- patching Sideboard config values
- resetting our database between tests
- starting up CherryPy
- establishing logged-in HTTP connections to restricted pages
* making websocket connections and making assertions about their traffic
Reply to this email directly or view it on GitHub: https://github.com/appliedsec/sideboard/issues/13
Ok, so this is almost completely done, which involved converting almost all of the SideboardServerTest subclasses to regular tests which run WAY faster now. I've kept some of the SideboardServerTest subclasses in their own file, which I'll probably move to a functional
subdirectory. Eventually we might get rid of them completely and replace them with Angular e2e tests, but until then they're work keeping around and just not running by default.
I should be able to put the last finishing touches on the new tests and make a pull request tomorrow.
BTW, for log capturing I've just been doing the same thing that I got used to doing in our Angular unit tests: monkeypatching e.g. log.error
with a mock, and then asserting that the mock was or was not called. I like the way the code for that looks better than the capsys examples I saw online.
The sideboard.tests module has a lot of utilities it provides in the form of two main base classes (SideboardTest and SideboardServerTest) which can be extended to get all the nice test methods.
However, it looks like we're definitely using pytest from now on, so we should pytest-ify these features. At first we'll need to keep the old ways around for backwards compatibility, and eventually we can get rid of them when no one is using them anymore.
At a glance, we need utility functions and pytest fixtures for doing the following things (this is not necessarily an exhaustive list):