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
43
44
45
46
47
48
49
50
51
52
53
54
|
import json
from tornado.web import Application
from tornado.testing import AsyncHTTPTestCase
from resources.handlers import VersionHandler, PodHandler, \
TestProjectHandler, TestCasesHandler, TestResultsHandler, DashboardHandler
import fake_pymongo
class TestBase(AsyncHTTPTestCase):
headers = {'Content-Type': 'application/json; charset=UTF-8'}
def setUp(self):
self.addCleanup(self._clear)
super(TestBase, self).setUp()
def get_app(self):
return Application(
[
(r"/version", VersionHandler),
(r"/pods", PodHandler),
(r"/pods/([^/]+)", PodHandler),
(r"/test_projects", TestProjectHandler),
(r"/test_projects/([^/]+)", TestProjectHandler),
(r"/test_projects/([^/]+)/cases", TestCasesHandler),
(r"/test_projects/([^/]+)/cases/([^/]+)", TestCasesHandler),
(r"/results", TestResultsHandler),
(r"/results([^/]*)", TestResultsHandler),
(r"/results/([^/]*)", TestResultsHandler),
(r"/dashboard", DashboardHandler),
(r"/dashboard([^/]*)", DashboardHandler),
(r"/dashboard/([^/]*)", DashboardHandler),
],
db=fake_pymongo,
debug=True,
)
def create(self, uri, body=None):
return self.fetch(uri,
method='POST',
body=json.dumps(body),
headers=self.headers)
def get(self, uri):
return self.fetch(uri,
method='GET',
headers=self.headers)
@staticmethod
def _clear():
fake_pymongo.pod.clear()
fake_pymongo.test_projects.clear()
fake_pymongo.test_cases.clear()
fake_pymongo.test_results.clear()
|