Skip to content

Commit

Permalink
Merge pull request #49 from EncryptEx/FIX/minor-changes
Browse files Browse the repository at this point in the history
FIX/minor changes
  • Loading branch information
EncryptEx authored Aug 25, 2023
2 parents 7a1c8bc + d1e727f commit 6469fb4
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 24 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ env/
env
__pycache__
modules/__pycache__/*
*.db
*.db
.vscode
.vscode/*
.idea
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

145 changes: 128 additions & 17 deletions tests.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,142 @@
# unit test

import unittest
import json
import unittest
from os import listdir
from os.path import isfile, join
from os.path import isfile
from os.path import join


def jsonToDict(filename):
with open(filename) as f_in:
return(json.load(f_in))

"""
:param filename:
"""
with open(filename) as f_in:
return json.load(f_in)


jsonRequiredLines = [
"help_description",
"help_moderation_title",
"user",
"reason",
"help_automod_title",
"help_automod_description",
"help_chatmod_title",
"help_chatmod_description",
"help_various_title",
"help_various_description",
"help_links_title",
"help_links_description",
"help_commands_title",
"help_commands_description",
"footer_executed_by",
"hello_command",
"error_deliver_msg",
"automod_warn_title",
"automod_warn_description",
"automod_warn_footer",
"automod_warn_reason",
"automod_count_title",
"automod_count_description",
"automod_removed_title",
"automod_removed_description",
"automod_nothappy_title",
"automod_nothappy_description",
"error_404",
"error_403",
"whois_title",
"whois_description",
"error_self_ban",
"punishment_default_reason",
"unpunishment_default_reason",
"ban_msg",
"ban_title",
"ban_description",
"error_ban_perm",
"error_self_kick",
"kick_msg",
"error_kick_perm",
"kick_title",
"kick_description",
"error_self_warn",
"warn_msg",
"warn_title",
"warn_description",
"warn_no_warns",
"seewarns_title",
"unwarn_no_warns",
"unwarn_description_msg",
"unwarn_wrong_selection",
"unwarn_msg",
"unwarn_title",
"unwarn_description",
"unwarn_count_with_success",
"plural_warn",
"singular_warn",
"clearwarns_msg",
"clearwarns_description",
"clearwarns_title",
"error_automod_syntax",
"automod_success_action",
"error_automod",
"modified",
"removed",
"setdelay_title",
"for",
"setdelay_description",
"mute_title",
"mute_description",
"mute_msg",
"unmute_msg",
"unmute_title",
"unmute_description",
"lock_title",
"lock_description",
"unlock_title",
"unlock_description",
"suggest_success",
"hammer_invite",
"hammer_link",
"enabled",
"disabled",
"settings_module",
"error_settings_syntax",
"settings_title",
"settings_description",
"settings_enable_automod",
"settings_disable_automod",
"settings_status",
"help_language_title",
"warns_line_loop",
"seewarns_chart_title",
]

jsonRequiredLines = ["help_description", "help_moderation_title", "user", "reason", "help_automod_title", "help_automod_description", "help_chatmod_title", "help_chatmod_description", "help_various_title", "help_various_description", "help_links_title", "help_links_description", "help_commands_title", "help_commands_description", "footer_executed_by", "hello_command", "error_deliver_msg", "automod_warn_title", "automod_warn_description", "automod_warn_footer", "automod_warn_reason", "automod_count_title", "automod_count_description", "automod_removed_title", "automod_removed_description", "automod_nothappy_title", "automod_nothappy_description", "error_404", "error_403", "whois_title", "whois_description", "error_self_ban", "punishment_default_reason", "unpunishment_default_reason", "ban_msg", "ban_title", "ban_description", "error_ban_perm", "error_self_kick", "kick_msg", "error_kick_perm", "kick_title", "kick_description", "error_self_warn", "warn_msg", "warn_title", "warn_description", "warn_no_warns", "seewarns_title", "unwarn_no_warns", "unwarn_description_msg", "unwarn_wrong_selection", "unwarn_msg", "unwarn_title", "unwarn_description", "unwarn_count_with_success", "plural_warn","singular_warn", "clearwarns_msg", "clearwarns_description", "clearwarns_title", "error_automod_syntax", "automod_success_action", "error_automod", "modified", "removed", "setdelay_title", "for", "setdelay_description", "mute_title", "mute_description", "mute_msg", "unmute_msg", "unmute_title", "unmute_description", "lock_title", "lock_description", "unlock_title", "unlock_description", "suggest_success", "hammer_invite", "hammer_link", "enabled", "disabled", "settings_module", "error_settings_syntax", "settings_title", "settings_description", "settings_enable_automod", "settings_disable_automod", "settings_status", "help_language_title", "warns_line_loop", "seewarns_chart_title"]

class HammerTest (unittest.TestCase):
class HammerTest(unittest.TestCase):
""" """

def test_lanugages(self):
langFiles = [f for f in listdir("./langs") if isfile(join("./langs", f))]
""" """
langFiles = [
f for f in listdir("./langs") if isfile(join("./langs", f))
]
for languageFile in langFiles:
filename = languageFile.split(".")[0]
dictionary = jsonToDict("./langs/"+languageFile)
self.assertEqual(len(dictionary.items()),len(jsonRequiredLines), "There's a missing line in the language json file: "+filename)
for k,v in dictionary.items():
self.assertTrue(k in jsonRequiredLines, "The line "+k+" is wrong spelled "+filename)



dictionary = jsonToDict("./langs/" + languageFile)
self.assertEqual(
len(dictionary.items()),
len(jsonRequiredLines),
"There's a missing line in the language json file: " +
filename,
)
for k, v in dictionary.items():
self.assertTrue(
k in jsonRequiredLines,
"The line " + k + " is wrong spelled " + languageFile,
)


if __name__ == "__main__":
unittest.main()
unittest.main()

0 comments on commit 6469fb4

Please sign in to comment.