mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-20 09:56:05 -05:00
[Trivia] Move Trivia lists back home (#2028)
* [Trivia] Move trivia lists back home Removes red-trivia as a dependency. Signed-off-by: Toby Harradine <tobyharradine@gmail.com> * Include package data in distribution Signed-off-by: Toby Harradine <tobyharradine@gmail.com> * Add test from red-trivia repo, and fix package data setup * The distribution will now include all files under any data/ sub-directory of a package, as well as all *.po files under any locales/ sub-directory (as it should have been before). * MANIFEST.in has been simplified to comply with these changes and redbot/cogs/audio/application.yml has been moved to the data/ sub-directory to maintain consistency in how we declare package data. Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
33
tests/cogs/test_trivia.py
Normal file
33
tests/cogs/test_trivia.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import yaml
|
||||
|
||||
|
||||
def test_trivia_lists():
|
||||
from redbot.cogs.trivia import get_core_lists
|
||||
|
||||
list_names = get_core_lists()
|
||||
assert list_names
|
||||
problem_lists = []
|
||||
for l in list_names:
|
||||
with l.open() as f:
|
||||
try:
|
||||
dict_ = yaml.load(f)
|
||||
except yaml.error.YAMLError as e:
|
||||
problem_lists.append((l.stem, "YAML error:\n{!s}".format(e)))
|
||||
else:
|
||||
for key in list(dict_.keys()):
|
||||
if key == "CONFIG":
|
||||
if not isinstance(dict_[key], dict):
|
||||
problem_lists.append((l.stem, "CONFIG is not a dict"))
|
||||
elif key == "AUTHOR":
|
||||
if not isinstance(dict_[key], str):
|
||||
problem_lists.append((l.stem, "AUTHOR is not a string"))
|
||||
else:
|
||||
if not isinstance(dict_[key], list):
|
||||
problem_lists.append(
|
||||
(l.stem, "The answers for '{}' are not a list".format(key))
|
||||
)
|
||||
if problem_lists:
|
||||
msg = ""
|
||||
for l in problem_lists:
|
||||
msg += "{}: {}\n".format(l[0], l[1])
|
||||
raise TypeError("The following lists contain errors:\n" + msg)
|
||||
Reference in New Issue
Block a user