-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathwebapps_tests.py
More file actions
63 lines (53 loc) · 2.29 KB
/
webapps_tests.py
File metadata and controls
63 lines (53 loc) · 2.29 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from time import sleep
from dataikuapi.dssclient import DSSClient
from dataikuapi.dss.project import DSSProject
from nose.tools import ok_
from nose.tools import eq_
host="http://localhost:8083"
apiKey="CMZBjFkUgcDh08S3awoPyVIweBelxPjy"
testProjectKey="WEBAPPS"
testWebAppPythonId="VCMN2ra"
def remove_key(d, key):
r = dict(d)
del r[key]
return r
class webapp_api_tests(object):
def setUp(self):
self.client = DSSClient(host, apiKey)
self.project = DSSProject(self.client, testProjectKey)
def list_webapps_test(self):
webapps = self.project.list_webapps();
ok_(len(webapps) > 0)
def get_python_webapp_test(self):
webapp = self.project.get_webapp(testWebAppPythonId)
ok_(webapp is not None)
def update_python_webapp_test(self):
webapp_pre = self.project.get_webapp(testWebAppPythonId)
webapp_pre.update()
webapp_post = self.project.get_webapp(testWebAppPythonId)
eq_(webapp_pre.project_key, webapp_post.project_key)
eq_(webapp_pre.webapp_id, webapp_post.webapp_id)
eq_(remove_key(webapp_pre.definition, "versionTag"), remove_key(webapp_post.definition, "versionTag"))
eq_(webapp_pre.definition["versionTag"]["versionNumber"]+1,webapp_post.definition["versionTag"]["versionNumber"])
def restart_backend_test(self):
"""
WARNING: you should manually stop the backend before this test
"""
filtered_webapps = [w for w in self.project.list_webapps() if w.webapp_id == testWebAppPythonId]
webapp = self.project.get_webapp(testWebAppPythonId)
ok_(not filtered_webapps[0].definition["backendRunning"],"The backend should be stopped before the test")
webapp.restart_backend()
sleep(2)
filtered_webapps = [w for w in self.project.list_webapps() if w.webapp_id == testWebAppPythonId]
ok_(filtered_webapps[0].definition["backendRunning"])
def stop_backend_test(self):
"""
WARNING: you should manually start the backend before this test
"""
filtered_webapps = [w for w in self.project.list_webapps() if w.webapp_id == testWebAppPythonId]
webapp = self.project.get_webapp(testWebAppPythonId)
ok_(filtered_webapps[0].definition["backendRunning"],"The backend should be started before the test")
webapp.stop_backend()
sleep(2)
filtered_webapps = [w for w in self.project.list_webapps() if w.webapp_id == testWebAppPythonId]
ok_(not filtered_webapps[0].definition["backendRunning"])