forked from FlashpointProject/Curation-Validation-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcuration_validator_test.py
289 lines (237 loc) · 15.2 KB
/
curation_validator_test.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
import unittest
from unittest.mock import patch
from curation_validator import validate_curation, CurationType
def mock_get_tag_list() -> list[str]:
return ["A", "B", "E"]
def mock_get_launch_commands_bluebot() -> list[str]:
return ["http://www.bluemaxima.org/a.html", "http://www.bluemaxima.org/b.html", "http://localflash/lab/c.html"]
class TestCurationValidator(unittest.TestCase):
def setUp(self):
self.tag_patcher = patch('curation_validator.get_tag_list')
self.tag_list = self.tag_patcher.start()
self.tag_list.side_effect = mock_get_tag_list
self.launch_command_patcher = patch('curation_validator.get_launch_commands_bluebot')
self.launch_command_list = self.launch_command_patcher.start()
self.launch_command_list.side_effect = mock_get_launch_commands_bluebot
def tearDown(self):
self.tag_patcher.stop()
self.launch_command_patcher.stop()
def test_valid_yaml_meta(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(f"test_curations/test_curation_valid.{extension}")
self.assertCountEqual(errors, [])
self.assertCountEqual(warnings, [])
self.assertFalse(is_extreme)
def test_invalid_yaml_meta_extreme(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(f"test_curations/test_curation_invalid_extreme.{extension}")
self.assertCountEqual(errors, ["Curation is extreme but lacks extreme tags."])
self.assertCountEqual(warnings, [])
self.assertTrue(is_extreme)
def test_valid_yaml_meta_extreme(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(f"test_curations/test_curation_valid_extreme.{extension}")
self.assertCountEqual(errors, [])
self.assertCountEqual(warnings, [])
self.assertTrue(is_extreme)
def test_valid_legacy(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(f"test_curations/test_curation_valid_legacy.{extension}")
self.assertCountEqual(errors, [])
self.assertCountEqual(warnings, [])
self.assertFalse(is_extreme)
def test_valid_legacy_genre(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(
f"test_curations/test_curation_valid_legacy_genre.{extension}")
self.assertCountEqual(errors, [])
self.assertCountEqual(warnings, [])
self.assertFalse(is_extreme)
def test_curation_invalid_archive(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(
f"test_curations/test_curation_invalid_archive.{extension}")
self.assertCountEqual(errors, [f"There seems to a problem with your {extension} file."])
self.assertCountEqual(warnings, [])
def test_curation_empty_meta(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(f"test_curations/test_curation_empty_meta.{extension}")
self.assertCountEqual(errors, ["The meta file seems to be empty."])
self.assertCountEqual(warnings, [])
def test_curation_duplicate_launch_command(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(
f"test_curations/test_curation_duplicate_launch_command.{extension}")
self.assertCountEqual(errors, [
"Identical launch command already present in the master database. Is your curation a duplicate?"])
self.assertCountEqual(warnings, [])
def test_curation_capital_extension_logo(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(
f"test_curations/test_curation_capital_extension_logo.{extension}")
self.assertCountEqual(errors, ["Logo file extension must be lowercase."])
self.assertCountEqual(warnings, [])
def test_curation_capital_extension_screenshot(self):
for extension in ["7z", "zip"]:
errors, warnings, is_extreme, _, _, _ = validate_curation(
f"test_curations/test_curation_capital_extension_screenshot.{extension}")
self.assertCountEqual(errors, ["Screenshot file extension must be lowercase."])
self.assertCountEqual(warnings, [])
# def test_curation_too_large(self):
# for extension in ["7z", "zip"]:
# errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_2GB.{extension}")
# self.assertCountEqual(errors, [])
# self.assertCountEqual(warnings, ["The archive is too large to be validated (`2000MB/1000MB`)."])
def test_curation_null_languages(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_nul_languages.{extension}")
self.assertCountEqual(errors, ["The `Languages` property in the meta file is mandatory."])
self.assertCountEqual(warnings, [])
def test_empty_content(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_empty_content.{extension}")
self.assertCountEqual(errors, ["No files found in content folder."])
self.assertCountEqual(warnings, [])
def test_missing_content(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_content.{extension}")
self.assertCountEqual(errors, ["Content folder not found."])
self.assertCountEqual(warnings, [])
def test_missing_logo(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_logo.{extension}")
self.assertCountEqual(errors, ["Logo file is either missing or its filename is incorrect."])
self.assertCountEqual(warnings, [])
def test_missing_meta(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_meta.{extension}")
self.assertCountEqual(errors,
[
"Meta file is either missing or its filename is incorrect. Are you using Flashpoint Core for curating?"])
self.assertCountEqual(warnings, [])
def test_missing_root_folder(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_root_folder.{extension}")
self.assertCountEqual(errors, [
"Logo, screenshot, content folder and meta not found. Is your curation structured properly?"])
self.assertCountEqual(warnings, [])
def test_missing_ss(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_ss.{extension}")
self.assertCountEqual(errors, ["Screenshot file is either missing or its filename is incorrect."])
self.assertCountEqual(warnings, [])
def test_unknown_tag_warning(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_unknown_tag.{extension}")
self.assertCountEqual(errors, [])
self.assertCountEqual(warnings,
["Tag `Unknown Tag` is not a known tag, please verify (did you write it correctly?).",
"Tag `Another Unknown Tag` is not a known tag, please verify (did you write it correctly?)."])
def test_missing_tags(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_tags.{extension}")
self.assertCountEqual(errors, ["Missing tags. At least one tag must be specified."])
self.assertCountEqual(warnings, [])
def test_missing_title(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_title.{extension}")
self.assertCountEqual(errors, ["The `Title` property in the meta file is mandatory."])
self.assertCountEqual(warnings, [])
def test_missing_application_path_warning(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(
f"test_curations/test_curation_missing_application_path.{extension}")
self.assertCountEqual(errors, ["The `Application Path` property in the meta file is mandatory."])
self.assertCountEqual(warnings, [])
def test_missing_launch_command(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_launch_command.{extension}")
self.assertCountEqual(errors, ["The `Launch Command` property in the meta file is mandatory."])
self.assertCountEqual(warnings, [])
def test_missing_languages(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_languages.{extension}")
self.assertCountEqual(errors, ["The `Languages` property in the meta file is mandatory."])
self.assertCountEqual(warnings, [])
def test_comma_in_languages(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_comma_in_languages.{extension}")
self.assertCountEqual(errors, ["Languages should be separated with semicolons, not commas."])
self.assertCountEqual(warnings, [])
def test_common_bad_language(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_common_bad_language.{extension}")
self.assertCountEqual(errors, ["The correct ISO 639-1 language code for Japanese is `ja`, not `jp`."])
self.assertCountEqual(warnings, [])
def test_language_name(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_language_name.{extension}")
self.assertCountEqual(errors, ["Languages must be in ISO 639-1 format, so please use `ja` instead of `Japanese`"])
self.assertCountEqual(warnings, [])
def test_missing_source(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_source.{extension}")
self.assertCountEqual(errors, ["The `Source` property in the meta file is mandatory."])
self.assertCountEqual(warnings, [])
def test_missing_status(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_missing_status.{extension}")
self.assertCountEqual(errors, ["The `Status` property in the meta file is mandatory."])
self.assertCountEqual(warnings, [])
def test_Norway(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_Norwegian.{extension}")
self.assertCountEqual(errors, [])
self.assertCountEqual(warnings, [])
def test_rar(self):
errors, warnings, _, _, _, _ = validate_curation("test_curations/test_curation_rar.rar")
self.assertCountEqual(errors, ["Curations must be either .zip or .7z, not .rar."])
self.assertCountEqual(warnings, [])
def test_trailing_language_semicolon(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_languages_semicolon.{extension}")
self.assertCountEqual(errors, [])
self.assertCountEqual(warnings, [])
def test_valid_date(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_invalid_date.{extension}")
self.assertCountEqual(errors, ["Invalid release date. Ensure entered date is valid."])
self.assertCountEqual(warnings, [])
def test_localflash_too_many_files(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_localflash_too_many_files.{extension}")
self.assertCountEqual(errors, ["Content must be in additional folder in localflash rather than in localflash directly."])
self.assertCountEqual(warnings, [])
def test_localflash_no_folder(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_localflash_no_folder.{extension}")
self.assertCountEqual(errors, ["Content must be in additional folder in localflash rather than in localflash directly."])
self.assertCountEqual(warnings, [])
def test_localflash_bad_name(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_localflash_bad_name.{extension}")
self.assertCountEqual(errors, ["Extremely common localflash containing folder name, please change."])
self.assertCountEqual(warnings, [])
def test_no_library(self):
for extension in ["7z", "zip"]:
errors, warnings, _, curation_type, _, _ = validate_curation(f"test_curations/test_curation_none_library.{extension}")
self.assertCountEqual(errors, [])
self.assertCountEqual(warnings, [])
self.assertEqual(curation_type, CurationType.FLASH_GAME)
def test_desktop_ini(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_desktop_ini.{extension}")
self.assertCountEqual(errors, ["desktop.ini file found in curation, please remove."])
self.assertCountEqual(warnings, [])
def test_three_letter_invalid_language(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_three_letter_lang_invalid.{extension}")
self.assertCountEqual(errors, ["Languages must be in ISO 639-1 format, so please use `en` instead of `eng`"])
self.assertCountEqual(warnings, [])
def test_three_letter_valid_language(self):
for extension in ["7z", "zip"]:
errors, warnings, _, _, _, _ = validate_curation(f"test_curations/test_curation_three_letter_lang_valid.{extension}")
self.assertCountEqual(errors, [])
self.assertCountEqual(warnings, [])
if __name__ == '__main__':
unittest.main()