diff options
| author | 2018-05-20 21:11:18 +0200 | |
|---|---|---|
| committer | 2018-05-20 21:11:18 +0200 | |
| commit | 687fedfffa402e049c59668f2a6248ad2ba17910 (patch) | |
| tree | 834e909781213650b40508398ed5a9bef10686c5 /tests/test_api.py | |
| parent | remove set -e (diff) | |
Tests directory (#73)
moves all tests into a testing directory and splits the tests into separate files
Diffstat (limited to '')
| -rw-r--r-- | tests/test_api.py | 25 | 
1 files changed, 25 insertions, 0 deletions
| diff --git a/tests/test_api.py b/tests/test_api.py new file mode 100644 index 00000000..a0b22846 --- /dev/null +++ b/tests/test_api.py @@ -0,0 +1,25 @@ +from tests import SiteTest, app + +class ApiEndpointsRootEndpoints(SiteTest): +    """ Test cases for the api subdomain """ +    def test_api_unknown_route(self): +        """ Check api unknown route """ +        response = self.client.get('/', app.config['API_SUBDOMAIN']) +        self.assertEqual(response.json, {'error_code': 0, 'error_message': 'Unknown API route'}) +        self.assertEqual(response.status_code, 404) + +    def test_api_healthcheck(self): +        """ Check healthcheck url responds """ +        response = self.client.get('/healthcheck', app.config['API_SUBDOMAIN']) +        self.assertEqual(response.json, {'status': 'ok'}) +        self.assertEqual(response.status_code, 200) + +    def test_api_route_errors(self): +        """ Check api route errors """ +        from pysite.base_route import APIView +        from pysite.constants import ErrorCodes + +        av = APIView() +        av.error(ErrorCodes.unauthorized) +        av.error(ErrorCodes.bad_data_format) + | 
