-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_backend.py
43 lines (37 loc) · 1.23 KB
/
test_backend.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
# Test cases for the backend
# call nosetests in same directory to run
import os
from nose.tools import *
from backend import *
toyDict = {'fruit':'apples\noranges\npears\npeaches\nraspberries\nstrawberries',
'animals':'pythons\nbears\njellyfish\ndolphins\nelephants',
'Sustainable Means of Transportation':'bicycling\nwalking\n'+\
'taking the train',
"A few of Drew's favorite things":'Stephanie Brabant\n'+\
'python programming language\n'+\
'bicycling\nstrawberries\n'}
def setup_func():
import os
global db
try:
os.makedirs('test/.notes')
except:
pass
try:
os.makedirs('test/notes')
except:
pass
#os.system('fusermount -u ' + os.path.abspath('test/notes'))
db = Database(location='test/notes',
encryptedLocation='test/.notes')
def teardown_func():
os.system('rm -rf test')
@with_setup(setup_func, teardown_func)
def test_decrypt():
db.load()
def test_database_sanity():
hits = db.search('oran')
assert hits==['fruit']
body = db.get_body_from_title(hits[0])
assert body == 'apples\noranges\npears\npeaches\raspberries\strawberries'
print 'Database Sanity Test Passed!'