-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtest.py
45 lines (32 loc) · 1.21 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
import unittest
from sucuri import Files
from sucuri import rendering
class TestFiles( unittest.TestCase ):
def test_add_files( self ):
files = Files()
name = 'test/inc/link.suc'
files.add( name )
self.assertEqual( ["a(href='#') {text}"], files.get( name ) )
def test_inject( self ):
files = Files()
param = {"text": "Hello!", "list": [1, 2, 3, 4]}
name = 'test/includefile.suc'
files.add( name )
rendered = files.template( name, param )
self.assertIn('<html>', rendered )
self.assertIn('</html>', rendered )
self.assertIn('<ul>', rendered )
self.assertIn('</ul>', rendered )
self.assertIn('<style>', rendered )
self.assertIn('</style>', rendered )
self.assertNotIn( 'test/inc/list', rendered )
self.assertNotIn( '+link', rendered )
def test_template( self ):
files = Files()
param = {"text": "Hello!", "list": [1, 2, 3, 4]}
name = 'test/includefile.suc'
files.add( name )
rendered = files.template( name, param )
self.assertEqual( rendered, rendering.template(name, param) )
if __name__ == '__main__':
unittest.main()