forked from LuRsT/pendium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
84 lines (73 loc) · 2.5 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
from pendium import app
from pendium.filesystem import (Wiki, PathNotFound, PathExists)
import unittest
class PendiumTestCase(unittest.TestCase):
def setUp(self):
config = app.config
self.w = Wiki(config['WIKI_DIR'],
extensions = config.get('WIKI_EXTENSIONS', {}),
default_renderer = config.get('WIKI_DEFAULT_RENDERER', None),
plugins_config = config.get('WIKI_PLUGINS_CONFIG', {}),
git_support = config.get('WIKI_GIT_SUPPORT', False))
return
def test_1_create_file(self):
try:
p = self.w.get('')
new_file = p.create_file('test_create.md')
assert new_file.is_leaf is True
assert new_file.is_node is False
assert new_file.is_binary is False
except PathExists:
self.fail('File already exists')
except Exception:
self.fail('Unexpected exception thrown')
def test_2_edit(self):
try:
p = self.w.get('test_create.md')
p.content('#header')
p.save()
assert p.can_render is True
assert p.render() == '<h1 id="header">header</h1>'
except Exception:
self.fail('Unexpected exception thrown')
def test_3_is_file(self):
w = Wiki('wiki')
try:
p = self.w.get('test_create.md')
assert p.is_leaf is True
assert p.is_node is False
assert p.is_binary is False
except Exception:
self.fail('Unexpected exception thrown')
def test_4_delete_file(self):
w = Wiki('wiki')
try:
p = self.w.get('test_create.md')
p.delete()
self.w.get('test_create.md')
except PathNotFound:
pass
except Exception:
self.fail('Unexpected exception thrown')
def test_is_dir(self):
w = Wiki('wiki')
try:
p = self.w.get('')
assert p.is_leaf is False
assert p.is_node is True
except Exception:
self.fail('Unexpected exception thrown')
def test_path_not_found(self):
w = Wiki('wiki')
try:
self.w.get('notafile.md')
except PathNotFound:
pass
except Exception:
self.fail('Unexpected exception thrown')
else:
self.fail('ExpectedException not thrown')
def tearDown(self):
return
if __name__ == '__main__':
unittest.main()