Add tests for Nginx config generator

This commit is contained in:
Thomas Leister 2025-03-27 16:12:18 +01:00
parent 4f3f4cd0dd
commit 7c3b5a2cb2
No known key found for this signature in database
GPG key ID: B7CFA61477D48DCB
2 changed files with 14 additions and 1 deletions

View file

@ -4,7 +4,7 @@
import json
import unittest
from robots import json_to_txt, json_to_table, json_to_htaccess
from robots import json_to_txt, json_to_table, json_to_htaccess, json_to_nginx
class RobotsUnittestExtensions:
def loadJson(self, pathname):
@ -50,6 +50,16 @@ class TestHtaccessGeneration(unittest.TestCase, RobotsUnittestExtensions):
robots_htaccess = json_to_htaccess(self.robots_dict)
self.assertEqualsFile("test_files/.htaccess", robots_htaccess)
class TestNginxConfigGeneration(unittest.TestCase, RobotsUnittestExtensions):
maxDiff = 8192
def setUp(self):
self.robots_dict = self.loadJson("test_files/robots.json")
def test_nginx_generation(self):
robots_nginx = json_to_nginx(self.robots_dict)
self.assertEqualsFile("test_files/nginx-block-ai-bots.conf", robots_nginx)
if __name__ == "__main__":
import os