Skip to content
Snippets Groups Projects
Unverified Commit 43128692 authored by David Hoese's avatar David Hoese
Browse files

Add test for main index page

parent 37358be0
Branches
No related tags found
No related merge requests found
...@@ -18,6 +18,21 @@ import json ...@@ -18,6 +18,21 @@ import json
# pass # pass
class TestIndex(unittest.TestCase):
def setUp(self):
import metobsapi
metobsapi.app.config['TESTING'] = True
metobsapi.app.config['DEBUG'] = True
self.app = metobsapi.app.test_client()
def tearDown(self):
pass
def test_index(self):
res = self.app.get('/api/')
self.assertIn(b'Metobs API', res.data)
class TestArchiveInfo(unittest.TestCase): class TestArchiveInfo(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
...@@ -38,6 +53,7 @@ class TestArchiveInfo(unittest.TestCase): ...@@ -38,6 +53,7 @@ class TestArchiveInfo(unittest.TestCase):
def setUp(self): def setUp(self):
import metobsapi import metobsapi
metobsapi.app.config['TESTING'] = True metobsapi.app.config['TESTING'] = True
metobsapi.app.config['DEBUG'] = True
metobsapi.app.config['ARCHIVE_ROOT'] = self.archive_dir metobsapi.app.config['ARCHIVE_ROOT'] = self.archive_dir
self.app = metobsapi.app.test_client() self.app = metobsapi.app.test_client()
......
...@@ -93,6 +93,13 @@ class TestDataAPI(unittest.TestCase): ...@@ -93,6 +93,13 @@ class TestDataAPI(unittest.TestCase):
self.assertIn('\'site\'', res['message']) self.assertIn('\'site\'', res['message'])
self.assertIn('\'inst\'', res['message']) self.assertIn('\'inst\'', res['message'])
def test_missing_symbols(self):
res = self.app.get('/api/data.json?begin=-05:00:00')
res = json.loads(res.data.decode())
self.assertEqual(res['code'], 400)
self.assertEqual(res['status'], 'error')
self.assertIn('\'symbols\'', res['message'])
def test_too_many_points(self): def test_too_many_points(self):
res = self.app.get('/api/data.json?symbols=aoss.tower.air_temp&begin=1970-01-01T00:00:00') res = self.app.get('/api/data.json?symbols=aoss.tower.air_temp&begin=1970-01-01T00:00:00')
self.assertEqual(res.status_code, 413) self.assertEqual(res.status_code, 413)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment