Added Test and Docu

This commit is contained in:
Julian Beittel 2025-04-23 09:41:18 +02:00
parent e519f9f94c
commit 1e92364c13
5 changed files with 19 additions and 57 deletions

View file

@ -4,7 +4,7 @@
import json
import unittest
from robots import json_to_txt, json_to_table, json_to_htaccess, json_to_nginx
from robots import json_to_txt, json_to_table, json_to_htaccess, json_to_nginx, json_to_caddy
class RobotsUnittestExtensions:
def loadJson(self, pathname):
@ -66,6 +66,17 @@ class TestRobotsNameCleaning(unittest.TestCase):
self.assertEqual(clean_robot_name("PerplexityUser"), "Perplexity-User")
class TestCaddyfileGeneration(unittest.TestCase, RobotsUnittestExtensions):
maxDiff = 8192
def setUp(self):
self.robots_dict = self.loadJson("test_files/robots.json")
def test_caddyfile_generation(self):
robots_caddyfile = json_to_caddy(self.robots_dict)
self.assertEqualsFile("test_files/Caddyfile", robots_caddyfile)
if __name__ == "__main__":
import os
os.chdir(os.path.dirname(__file__))