-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_add2couchdb.py
35 lines (28 loc) · 1.25 KB
/
test_add2couchdb.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
import unittest
from OBSCouchDB import OBSCouchDB
class Add(unittest.TestCase):
obsCdb = None
test_link = "https://github.com/vrtmrz/obsidian-livesync/"
# target_doc_id = "UndefinedDummyFailure"
target_doc_id = "1-Obsidian/Test.md" # change this to an existing document in Obsidian
def setUp(self):
self.obsCdb = OBSCouchDB(self.target_doc_id)
self.assertTrue(self.obsCdb.init_ok, self.obsCdb.error_msg)
self.obsCdb.trace = True
def test01_add_content(self):
self.assertTrue(self.obsCdb!=None)
status = self.obsCdb.add_content(self.test_link)
print(status)
self.assertEqual(status, f"Appended content to {self.target_doc_id}")
def test02_get_last_child(self):
self.assertTrue(self.obsCdb!=None)
result = self.obsCdb.get_last_child()
data = result['data'].strip()
self.assertEqual(data, self.test_link)
# comment this test out if you want to manually check in Obsidian if the link has been added
def test03_delete_last_child(self):
self.assertTrue(self.obsCdb!=None)
result = self.obsCdb.delete_last_child()
self.assertTrue(result)
if __name__ == '__main__':
unittest.main(failfast=True)