-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
84 lines (68 loc) · 2.87 KB
/
tests.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import os
import unittest
from fluidily import Fluidily, FluidilyError
try:
import fluidily_config # noqa
except ImportError:
pass
test_app = 'fluid-test'
test_organisation = os.environ.get('FLUIDILY_ORGANISATION')
client = Fluidily(os.environ.get('FLUIDILY_URL'),
token=os.environ.get('FLUIDILY_TOKEN'))
class TestFluidily(unittest.TestCase):
@classmethod
def setUpClass(cls):
try:
client.applications.delete(test_app)
except FluidilyError as exc:
if exc.status_code != 404:
raise
client.applications.create(name=test_app,
organisation=test_organisation)
@classmethod
def tearDownClass(cls):
client.applications.delete(test_app)
# INFO
def test_urls(self):
self.assertTrue(client.urls())
def test_version(self):
self.assertTrue(client.version()['version'])
def test_packages(self):
packages = client.python()
self.assertTrue(packages['python'])
self.assertTrue(packages['pulsar'])
self.assertTrue(packages['lux'])
def test_get_token_fail(self):
with self.assertRaises(FluidilyError) as e:
client.get_token(username='foo', password='dvvddvd')
self.assertEqual(e.exception.status_code, 422)
# APPLICATIONS
def test_applications_get_list(self):
apps = client.applications.get_list()
self.assertTrue(apps)
# TEMPLATES
def test_template_create_fail(self):
with self.assertRaises(FluidilyError) as e:
client.templates.create(slug='test', body='{{ html_main }}')
self.assertEqual(e.exception.status_code, 422)
with self.assertRaises(FluidilyError) as e:
client.templates.get('%s/test' % test_app)
self.assertEqual(e.exception.status_code, 404)
def test_template_create_success(self):
result = client.templates.create(slug='test1',
body='{{ html_main }}',
application=test_app)
self.assertEqual(result['slug'], 'test1')
result = client.templates.get('%s/test1' % test_app)
self.assertEqual(result['slug'], 'test1')
def test_template_update_success(self):
result = client.templates.create(slug='test2',
body='{{ html_main }}',
application=test_app)
self.assertEqual(result['slug'], 'test2')
result = client.templates.get('%s/test2' % test_app)
self.assertEqual(result['slug'], 'test2')
result = client.templates.update('%s/test2' % test_app,
body='<navbar></navbar>'
'{{ html_main }}')
self.assertEqual(result['body'], '<navbar></navbar>{{ html_main }}')