-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·54 lines (40 loc) · 1.47 KB
/
test.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
import os
import time
from flask.ext.testing import TestCase as FlaskTestCase
from unittest import TestCase
from duchess import create_app
from utils import autocompiler
class ViewsTest(FlaskTestCase):
def create_app(self):
duchess = create_app()
return duchess
def test_app(self):
from flask import Flask
duchess = self.create_app()
print(duchess.config)
self.assertIsInstance(duchess, Flask)
self.assertTrue(duchess.testing)
def test_index(self):
r = self.client.get('/')
self.assert_200(r)
def test_asdf(self):
r = self.client.get('/asdf/')
self.assert_404(r)
class AutocompilerTest(TestCase):
@classmethod
def setup_class(cls):
with open('duchess/assets/css/test.sass', 'w') as sass_file:
sass_file.write('$c = black\na\n color: $c\n')
autocompiler.watch_assets('duchess/assets')
time.sleep(1)
@classmethod
def teardown_class(cls):
os.remove('duchess/assets/css/test.sass')
os.remove('duchess/assets/css/test.min.css')
def test_autocompiler(self):
with open('duchess/assets/css/test.sass', 'w') as sass_file:
sass_file.write('$c = white\na\n color: $c\n')
time.sleep(1)
with open('duchess/assets/css/test.min.css', 'r') as css_file:
self.assertEqual(css_file.read(), 'a{color:white}')
self.assertRaises(IOError, open, 'duchess/assets/css/test.sass.css')