forked from nicolas-van/pygreen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
49 lines (38 loc) · 1.51 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
from __future__ import unicode_literals, print_function
import unittest
import pygreen
import shutil
import os
import os.path
_folder = os.path.join(os.path.dirname(__file__), "tests")
_output = os.path.join(_folder, "output")
class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
os.makedirs(_output)
self.pygreen = pygreen.PyGreen()
def tearDown(self):
self.pygreen = None
shutil.rmtree(_output)
def test_static_get(self):
self.pygreen.set_folder(os.path.join(_folder, "input_static_get"))
value = self.pygreen.get("test.txt")
self.assertEqual(value.strip(), b"test")
def test_mako(self):
self.pygreen.set_folder(os.path.join(_folder, "input_mako"))
value = self.pygreen.get("test.html")
self.assertEqual(value.strip(), b"3+2=5")
def test_gen(self):
self.pygreen.set_folder(os.path.join(_folder, "input_gen"))
value = self.pygreen.gen_static(_output)
with open(os.path.join(_output, "test.txt"), "rb") as _file:
value = _file.read()
self.assertEqual(value.strip(), b"test")
with open(os.path.join(_output, "test.html"), "rb") as _file:
value = _file.read()
self.assertEqual(value.strip(), b"3+2=5")
def test_markdown(self):
self.pygreen.set_folder(os.path.join(_folder, "input_markdown"))
value = self.pygreen.get("test.html")
self.assertEqual(value.strip(), b"<h1>Test</h1>")
if __name__ == '__main__':
unittest.main()