-
Notifications
You must be signed in to change notification settings - Fork 327
/
Copy pathgeeknoteTest.py
93 lines (76 loc) · 2.97 KB
/
geeknoteTest.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
85
86
87
88
89
90
91
92
93
# -*- coding: utf-8 -*-
import time
import unittest
from geeknote.geeknote import *
from geeknote import tools
from geeknote.editor import Editor
class GeekNoteOver(GeekNote):
def __init__(self):
pass
def loadNoteContent(self, note):
note.content = "note content"
class NotesOver(Notes):
def connectToEvertone(self):
self.evernote = GeekNoteOver()
class testNotes(unittest.TestCase):
def setUp(self):
self.notes = NotesOver()
self.testNote = tools.Struct(title="note title")
def test_parseInput1(self):
testData = self.notes._parseInput("title", "test body", "tag1")
self.assertTrue(isinstance(testData, dict))
if not isinstance(testData, dict):
return
self.assertEqual(testData['title'], "title")
self.assertEqual(testData['content'], Editor.textToENML("test body"))
self.assertEqual(testData["tags"], ["tag1", ])
def test_parseInput2(self):
testData = self.notes._parseInput("title", "WRITE", "tag1, tag2",
None, self.testNote)
self.assertTrue(isinstance(testData, dict))
if not isinstance(testData, dict):
return
self.assertEqual(testData['title'], "title")
self.assertEqual(
testData['content'],
"WRITE"
)
self.assertEqual(testData["tags"], ["tag1", "tag2"])
def test_editWithEditorInThread(self):
testData = self.notes._parseInput("title", "WRITE", "tag1, tag2",
None, self.testNote)
print ('')
print ('')
print (testData)
print ('')
print ('')
self.notes._editWithEditorInThread(testData)
def test_createSearchRequest1(self):
testRequest = self.notes._createSearchRequest(
search="test text",
tags="tag1",
notebooks="test notebook",
date="01.01.2000",
exact_entry=True,
content_search=True
)
response = 'notebook:"test notebook" tag:"tag1" ' \
'created:20000101 -created:20000102 "test text"'
self.assertEqual(testRequest, response)
def test_createSearchRequest2(self):
testRequest = self.notes._createSearchRequest(
search="test text",
tags="tag1, tag2",
notebooks="notebook1, notebook2",
date="31.12.1999-31.12.2000",
exact_entry=False,
content_search=False
)
response = 'notebook:"notebook1" notebook:"notebook2" tag:"tag1"' \
' tag:"tag2" created:19991231 -created:20010101 ' \
'intitle:test text'
self.assertEqual(testRequest, response)
def testError_createSearchRequest1(self):
testRequest = self.notes._createSearchRequest(search="test text",
date="12.31.1999")
self.assertEqual(testRequest, 'exit')