-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest_multiclipboard.py
107 lines (80 loc) · 3.13 KB
/
test_multiclipboard.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import shelve
import sys
import pyperclip
import pytest
from multiclipboard import mcb
shelf = shelve.open('multiclipboard/test')
shelf.clear()
assert len(shelf) == 0
def entry_setup():
pyperclip.copy('test1 text replaced')
mcb.save_entry(shelf, 'test1')
pyperclip.copy('test2 text')
mcb.save_entry(shelf, 'test2')
@pytest.mark.skipif(sys.platform == 'linux',
reason="Pyperclip requires a copy/paste mechanism. "
"Cannot get any of these mechanisms to function "
"on Travis' linux vm. Only disabled for CI",
allow_module_level=True)
def test_save_entry():
pyperclip.copy('test1 text')
mcb.save_entry(shelf, 'test1')
assert len(shelf) == 1
pyperclip.copy('test2 text')
mcb.save_entry(shelf, 'test2')
assert len(shelf) == 2
pyperclip.copy('test1 text replaced')
mcb.save_entry(shelf, 'test1')
assert len(shelf) == 2
shelf.clear()
@pytest.mark.skipif(sys.platform == 'linux',
reason="Pyperclip requires a copy/paste mechanism. "
"Cannot get any of these mechanisms to function "
"on Travis' linux vm. Only disabled for CI",
allow_module_level=True)
def test_list_entries():
entry_setup()
mcb.list_entries(shelf)
entries = pyperclip.paste()
assert 'test1' in entries
assert 'test2' in entries
shelf.clear()
@pytest.mark.skipif(sys.platform == 'linux',
reason="Pyperclip requires a copy/paste mechanism. "
"Cannot get any of these mechanisms to function "
"on Travis' linux vm. Only disabled for CI",
allow_module_level=True)
def test_get_entry():
entry_setup()
mcb.get_entry(shelf, 'test1')
assert 'test1 text replaced' == pyperclip.paste()
shelf.clear()
@pytest.mark.skipif(sys.platform == 'linux',
reason="Pyperclip requires a copy/paste mechanism. "
"Cannot get any of these mechanisms to function "
"on Travis' linux vm. Only disabled for CI",
allow_module_level=True)
def test_delete_entry():
entry_setup()
assert len(shelf) == 2
mcb.delete_entry(shelf, 'test2')
assert len(shelf) == 1
mcb.delete_entry(shelf, 'junk')
assert pyperclip.paste() == 'Error: deletion failed as there is no ' \
'saved entry that matches "junk"'
assert len(shelf) == 1
shelf.clear()
@pytest.mark.skipif(sys.platform == 'linux',
reason="Pyperclip requires a copy/paste mechanism. "
"Cannot get any of these mechanisms to function "
"on Travis' linux vm. Only disabled for CI",
allow_module_level=True)
def test_delete_all_entries():
pyperclip.copy('test1 text')
mcb.save_entry(shelf, 'test1')
assert len(shelf) == 1
mcb.save_entry(shelf, 'test2')
assert len(shelf) == 2
mcb.delete_all_entries(shelf)
assert len(shelf) == 0
shelf.clear()