-
Notifications
You must be signed in to change notification settings - Fork 0
/
exif_editor_tester.py
128 lines (109 loc) · 4.26 KB
/
exif_editor_tester.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import unittest
from exif_editor import ExifEditor
class TestKeywordReader(unittest.TestCase):
global jpg
global png
jpg = ExifEditor("images/forest.jpg")
png = ExifEditor("images/girl.png")
def setUp(self):
jpg.clear_keywords()
png.clear_keywords()
def test_add_keyword(self):
jpg.add_keyword("soup")
png.add_keyword("bow")
self.assertEqual(jpg.keywords, ["soup"])
self.assertEqual(png.keywords, ["bow"])
def test_add_multiple_keywords(self):
jpg.add_keyword("soup")
jpg.add_keyword("ramen")
png.add_keyword("bow")
png.add_keyword("arrow")
self.assertEqual(jpg.keywords, ["soup", "ramen"])
self.assertEqual(png.keywords, ["bow", "arrow"])
def test_add_duplicate_keywords(self):
jpg.add_keyword("soup")
jpg.add_keyword("soup")
png.add_keyword("bow")
png.add_keyword("bow")
self.assertEqual(jpg.keywords, ["soup"])
self.assertEqual(png.keywords, ["bow"])
def test_add_keywords_with_semicolons(self):
jpg.add_keyword("soup;ramen")
png.add_keyword("bow;arrow")
self.assertEqual(jpg.keywords, ["soup", "ramen"])
self.assertEqual(png.keywords, ["bow", "arrow"])
def test_add_keywords_with_semicolons_and_spaces(self):
jpg.add_keyword("soup; ramen")
png.add_keyword("bow; arrow")
self.assertEqual(jpg.keywords, ["soup", "ramen"])
self.assertEqual(png.keywords, ["bow", "arrow"])
def test_add_keywords_with_semicolons_and_spaces_and_duplicates(self):
jpg.add_keyword("soup; ramen")
jpg.add_keyword("soup; ramen")
png.add_keyword("bow; arrow")
png.add_keyword("bow; arrow")
self.assertEqual(jpg.keywords, ["soup", "ramen"])
self.assertEqual(png.keywords, ["bow", "arrow"])
def test_add_keywords_with_semicolons_and_spaces_and_duplicates_and_multiple_keywords(self):
jpg.add_keyword("soup; ramen")
jpg.add_keyword("soup; ramen")
jpg.add_keyword("soup")
jpg.add_keyword("ramen")
png.add_keyword("bow; arrow")
png.add_keyword("bow; arrow")
png.add_keyword("bow")
png.add_keyword("arrow")
self.assertEqual(jpg.keywords, ["soup", "ramen"])
self.assertEqual(png.keywords, ["bow", "arrow"])
def test_add_keywords_with_semicolons_and_spaces_and_duplicates_and_multiple_keywords_and_remove_duplicates(self):
jpg.add_keyword("soup; ramen")
jpg.add_keyword("soup; ramen")
jpg.add_keyword("soup")
jpg.add_keyword("ramen")
jpg.remove_keyword("soup")
jpg.remove_keyword("ramen")
png.add_keyword("bow; arrow")
png.add_keyword("bow; arrow")
png.add_keyword("bow")
png.add_keyword("arrow")
png.remove_keyword("bow")
png.remove_keyword("arrow")
self.assertEqual(jpg.keywords, [])
self.assertEqual(png.keywords, [])
def test_remove_keyword(self):
jpg.add_keyword("soup")
jpg.remove_keyword("soup")
png.add_keyword("bow")
png.remove_keyword("bow")
self.assertEqual(jpg.keywords, [])
self.assertEqual(png.keywords, [])
def test_remove_multiple_keywords(self):
jpg.add_keyword("soup")
jpg.add_keyword("ramen")
jpg.remove_keyword("soup")
jpg.remove_keyword("ramen")
png.add_keyword("bow")
png.add_keyword("arrow")
png.remove_keyword("bow")
png.remove_keyword("arrow")
self.assertEqual(jpg.keywords, [])
self.assertEqual(png.keywords, [])
def test_remove_keyword_not_in_list(self):
jpg.add_keyword("soup")
jpg.remove_keyword("ramen")
png.add_keyword("bow")
png.remove_keyword("arrow")
self.assertEqual(jpg.keywords, ["soup"])
self.assertEqual(png.keywords, ["bow"])
def test_remove_keyword_with_semicolons(self):
jpg.add_keyword("soup; ramen")
jpg.remove_keyword("soup")
png.add_keyword("bow; arrow")
png.remove_keyword("bow")
self.assertEqual(jpg.keywords, ["ramen"])
self.assertEqual(png.keywords, ["arrow"])
def tearDown(self):
jpg.close_image()
png.close_image()
if __name__ == '__main__':
unittest.main()