-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app.py
More file actions
42 lines (32 loc) · 1.36 KB
/
test_app.py
File metadata and controls
42 lines (32 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import unittest
from flask import json
from app import app, engine, metadata
class AppTest(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
metadata.create_all(engine)
def test_pr_created_per_month(self):
response = self.app.get('/pr-created')
self.assertEqual(response.status_code, 200)
data = json.loads(response.get_data(as_text=True))
self.assertIsInstance(data, list)
def test_commits_count_per_push(self):
response = self.app.get('/push-data')
self.assertEqual(response.status_code, 200)
data = json.loads(response.get_data(as_text=True))
self.assertIsInstance(data, list)
def test_file_changes_per_commit(self):
response = self.app.get('/commits-data')
self.assertEqual(response.status_code, 200)
data = json.loads(response.get_data(as_text=True))
self.assertIsInstance(data, list)
def test_health_check(self):
response = self.app.get('/')
self.assertEqual(response.status_code, 200)
data = json.loads(response.get_data(as_text=True))
self.assertEqual(data, {"status": "analytics service is healthy"})
def test_invalid_endpoint(self):
response = self.app.get('/invalid-endpoint')
self.assertEqual(response.status_code, 404)
if __name__ == '__main__':
unittest.main()