Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upTests directory #73
Tests directory #73
Conversation
|
some thoughts and ideas |
| try: | ||
| del os.environ["FLASK_DEBUG"] # Some unit tests fail if this is set | ||
| except KeyError: | ||
| pass |
This comment has been minimized.
This comment has been minimized.
jchristgit
May 20, 2018
Member
Probably just me, but I think just checking whether it exists would be a fair bit cleaner.
if "FLASK_DEBUG" in os.environ:
del os.environ["FLASK_DEBUG"] # Some unit tests fail if this is set
This comment has been minimized.
This comment has been minimized.
| @@ -0,0 +1,25 @@ | |||
| from tests import SiteTest, app | |||
|
|
|||
| class ApiEndpointsRootEndpoints(SiteTest): | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| - snake_idioms | ||
| - snake_facts | ||
| """ | ||
| os.environ['BOT_API_KEY'] = 'abcdefg' |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| try: | ||
| try_json_type("not json") | ||
| except Exception as error_message: | ||
| self.assertEqual(type(error_message), AttributeError) |
This comment has been minimized.
This comment has been minimized.
jchristgit
May 20, 2018
Member
how about assertRaises instead?
with self.assertRaises(AttributeError):
try_json_type("not json")
This comment has been minimized.
This comment has been minimized.
| rv.setup(manager, 'sdfsdf') | ||
| except RuntimeError: | ||
| return True | ||
| raise Exception('Expected runtime error on setup() when giving wrongful arguments') |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| def test_logout(self): | ||
| """ Make sure at least apart of logout is working :/ """ | ||
| self.assertIs(manager.oauth_backend.logout(), None) |
This comment has been minimized.
This comment has been minimized.
jchristgit
May 20, 2018
Member
these would probably all be cleaner with the assertIsNone as shown above
This comment has been minimized.
This comment has been minimized.
| def test_error(self): | ||
| """ Check the /error/XYZ page """ | ||
| response = self.client.get('/error/418') | ||
| self.assertEqual(response.status_code, 418) |
This comment has been minimized.
This comment has been minimized.
jchristgit
May 20, 2018
Member
this only checks a single error page, i'm not sure if it's desired, but how about checking all of them with something like
for code in HANDLED_ERROR_CODES:
response = self.client.get(f'/error/{code}')
self.assertEqual(response.status_code, code)
This comment has been minimized.
This comment has been minimized.
Inveracity
May 20, 2018
Author
Contributor
The other status codes are satisfied in other tests, but I do like this, so I'm gonna try it
This comment has been minimized.
This comment has been minimized.
| ev.setup(manager, 'sdfsdf') | ||
| except RuntimeError: | ||
| return True | ||
| raise Exception('Expected runtime error on setup() when giving wrongful arguments') |
This comment has been minimized.
This comment has been minimized.
| TestWS(None).on_message("test") | ||
| return False | ||
| except NotImplementedError: | ||
| return True |
This comment has been minimized.
This comment has been minimized.
jchristgit
May 20, 2018
Member
what would return True / return False do in a test? self.assertRaises is probably also wanted here?
This comment has been minimized.
This comment has been minimized.
| @@ -2,5 +2,5 @@ | |||
| max-line-length=120 | |||
| application_import_names=pysite | |||
| ignore=P102,B311,W503,E226,S311 | |||
| exclude=__pycache__, venv, app_test.py, .venv | |||
| exclude=__pycache__, venv, .venv, tests | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Inveracity
May 20, 2018
Author
Contributor
we exclude tests from linting because some tests require some terrible python code that flake8 really dislikes
|
|
Inveracity commentedMay 20, 2018