-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_note.py
89 lines (71 loc) · 2.28 KB
/
test_note.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
#!/usr/bin/env python3
# Copyright (c) 2023 note.py authors
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
import note
class FakeNoteCollection:
def __init__(self):
pass
def note_changed(self):
pass
class FakePersistence:
def __init__(self):
pass
def read_note(self, name):
return ""
def write_note(self, name, contents):
pass
def read_tags(self, name):
return []
def write_tags(self, name, tags):
pass
def rename_note(self, old_name, new_name):
pass
def test_get_name():
collection = FakeNoteCollection()
persistence = FakePersistence()
n = note.Note(collection, persistence, "test")
assert("test" == n.name())
def test_set_name():
collection = FakeNoteCollection()
persistence = FakePersistence()
n = note.Note(collection, persistence, "test")
n.name("new name")
assert("new name" == n.name())
def test_get_contents():
collection = FakeNoteCollection()
persistence = FakePersistence()
n = note.Note(collection, persistence, "test")
assert("" == n.contents())
def test_set_contents():
collection = FakeNoteCollection()
persistence = FakePersistence()
n = note.Note(collection, persistence, "test")
n.contents("brummni")
assert("brummni" == n.contents())
def test_get_tags():
collection = FakeNoteCollection()
persistence = FakePersistence()
n = note.Note(collection, persistence, "test")
assert([] == n.tags())
def test_set_tags():
collection = FakeNoteCollection()
persistence = FakePersistence()
n = note.Note(collection, persistence, "test")
n.tags(["foo"])
assert(["foo"] == n.tags())
def test_matches_name():
collection = FakeNoteCollection()
persistence = FakePersistence()
n = note.Note(collection, persistence, "test")
assert(n.matches("test", []))
assert(not n.matches("foo", []))
def test_matches_tag():
collection = FakeNoteCollection()
persistence = FakePersistence()
n = note.Note(collection, persistence, "test")
n.tags(["foo"])
assert(n.matches("", ["foo"]))
assert(not n.matches("", ["bar"]))