diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a3966ab..38210de 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,8 +1,5 @@
image: python:3.7-alpine
-include:
- - template: Code-Quality.gitlab-ci.yml
-
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
diff --git a/test/mockserver/configs/settings2.json b/test/mockserver/configs/settings2.json
index 1cf300b..4bdaecc 100644
--- a/test/mockserver/configs/settings2.json
+++ b/test/mockserver/configs/settings2.json
@@ -21,7 +21,7 @@
"show_updown_messages": true,
"ignored_namespaces": [],
"extensions_dir": "extensions",
- "error_tolerance": 0,
+ "error_tolerance": 2,
"overview": true,
"overview_time": "00:00",
"send_empty_overview": true,
diff --git a/test/test_disconnection.py b/test/test_disconnection.py
new file mode 100644
index 0000000..6218f44
--- /dev/null
+++ b/test/test_disconnection.py
@@ -0,0 +1,31 @@
+# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
+#
+# RcGcDw is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# RcGcDw is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with RcGcDw. If not, see .
+
+import unittest
+from test.test_utilities import inject_settings
+from src.wiki import Wiki
+
+
+class login_Testing(unittest.TestCase):
+ wiki = Wiki(None, None)
+
+ def test_connection_checker(self):
+ self.assertTrue(self.wiki.check_connection(looped=True))
+
+ def test_connection_tracker1(self): # expands this test
+ inject_settings("show_updown_messages", True)
+ self.wiki.downtimecredibility = 0
+ self.wiki.downtime_controller(True)
+ self.assertTrue(self.wiki.downtimecredibility > 0)
diff --git a/test/test_i18n.py b/test/test_i18n.py
new file mode 100644
index 0000000..0cccef5
--- /dev/null
+++ b/test/test_i18n.py
@@ -0,0 +1,30 @@
+# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
+#
+# RcGcDw is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# RcGcDw is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with RcGcDw. If not, see .
+
+from test.test_utilities import inject_settings
+import src.i18n
+import unittest
+
+
+class i18nTesting(unittest.TestCase):
+ def test_language_output_polish(self):
+ inject_settings("lang", "pl")
+ src.i18n.load_languages() # reload languages with new language
+ self.assertEqual(src.i18n.rcgcdw.gettext("Daily overview"), "Podsumowanie dnia")
+
+ def test_language_output_english(self):
+ inject_settings("lang", "en")
+ src.i18n.load_languages() # reload languages with new language
+ self.assertEqual(src.i18n.rcgcdw.gettext("Daily overview"), "Daily overview")
diff --git a/test/test_queue.py b/test/test_queue.py
new file mode 100644
index 0000000..66b3161
--- /dev/null
+++ b/test/test_queue.py
@@ -0,0 +1,66 @@
+# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
+#
+# RcGcDw is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# RcGcDw is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with RcGcDw. If not, see .
+
+import unittest
+from typing import Tuple
+
+from src.discord.queue import MessageQueue
+from src.discord.message import DiscordMessage, DiscordMessageMetadata
+
+
+def create_dummy(id: int = 0, **kwargs) -> Tuple[DiscordMessage, DiscordMessageMetadata]:
+ dm = DiscordMessage(event_type="log/{}".format(id), message_type="embed", webhook_url="https://example.com/")
+ dmm = DiscordMessageMetadata("POST", log_id=kwargs.get("log_id", int(id)*10), page_id=kwargs.get("page_id", int(id)),
+ rev_id=kwargs.get("rev_id", int(id)*10), webhook_url=kwargs.get("webhook_url", "https://example.com/"))
+ return dm, dmm
+
+
+class TestQueue(unittest.TestCase):
+ def test_add_message(self):
+ queue = MessageQueue()
+ for _ in range(100):
+ queue.add_message(create_dummy())
+ self.assertEqual(len(queue), 100)
+
+ def test_cut_messages(self):
+ queue = MessageQueue()
+ for num in range(100):
+ queue.add_message(create_dummy(id=num))
+ queue.cut_messages(10)
+ self.assertEqual(list(queue)[0][1].page_id, 10)
+
+ def test_compare_message_to_dict(self):
+ queue = MessageQueue()
+ passing = [create_dummy(id=103, page_id=3928, rev_id=228848), create_dummy(id=108, page_id=3928, rev_id=228853)]
+ failing = [create_dummy(id=105, page_id=39, rev_id=2288), create_dummy(id=110, page_id=392, rev_id=228)]
+ for msg in passing:
+ with self.subTest():
+ self.assertTrue(queue.compare_message_to_dict(msg[1], {"page_id": 3928}))
+ for msg in failing:
+ with self.subTest():
+ self.assertFalse(queue.compare_message_to_dict(msg[1], {"page_id": 3928}))
+
+ def test_delete_all_with_matching_metadata(self):
+ queue = MessageQueue()
+ queue.add_message(create_dummy(id=103, page_id=500, rev_id=228844))
+ for num in range(100):
+ queue.add_message(create_dummy(id=num))
+ queue.add_message(create_dummy(id=105, page_id=3923, rev_id=228848))
+ queue_correct = MessageQueue()
+ for num in range(100):
+ queue_correct.add_message(create_dummy(id=num))
+ queue_correct.add_message(create_dummy(id=105, page_id=3923, rev_id=228848))
+ queue.delete_all_with_matching_metadata(page_id=500)
+ self.assertEqual(len(queue), len(queue_correct)) # Could be better but I'm running out of time
diff --git a/test/test_utilities.py b/test/test_utilities.py
new file mode 100644
index 0000000..d5c73bf
--- /dev/null
+++ b/test/test_utilities.py
@@ -0,0 +1,25 @@
+# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
+#
+# RcGcDw is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# RcGcDw is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with RcGcDw. If not, see .
+from typing import Any
+
+import src.configloader
+
+
+def inject_settings(setting: str, value: Any):
+ path = setting.split(".")
+ dic = src.configloader.settings
+ for key in path[:-1]:
+ dic = dic[key]
+ dic[path[-1]] = value
\ No newline at end of file
diff --git a/test/test_wiki_login.py b/test/test_wiki_login.py
new file mode 100644
index 0000000..482afeb
--- /dev/null
+++ b/test/test_wiki_login.py
@@ -0,0 +1,53 @@
+# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
+#
+# RcGcDw is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# RcGcDw is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with RcGcDw. If not, see .
+
+import unittest
+from src.configloader import settings
+from test.test_utilities import inject_settings
+from src.wiki import Wiki
+
+
+def cleanup_func(func):
+ def wrap(*args, **kwargs):
+ login = settings["wiki_bot_login"]
+ password = settings["wiki_bot_password"]
+ func(*args, **kwargs)
+ inject_settings("wiki_bot_login", login)
+ inject_settings("wiki_bot_password", password)
+ return func
+ return wrap
+
+
+class login_Testing(unittest.TestCase):
+ wiki = Wiki(None, None)
+
+ def test_success(self):
+ self.wiki.logged_in = False
+ self.wiki.log_in()
+ self.assertTrue(self.wiki.logged_in)
+
+ @cleanup_func
+ def test_failure1(self):
+ self.wiki.logged_in = False
+ inject_settings("wiki_bot_login", "asdkaodhasofaufbasf")
+ with self.assertLogs("rcgcdw.rc", level="ERROR"):
+ self.wiki.log_in()
+
+ @cleanup_func
+ def test_failure2(self):
+ self.wiki.logged_in = False
+ inject_settings("wiki_bot_password", "lkkkkk")
+ with self.assertLogs("rcgcdw.rc", level="ERROR"):
+ self.wiki.log_in()