From ffad9293c46281f5f8639644c01cc3547a86aeb7 Mon Sep 17 00:00:00 2001 From: guest20 Date: Tue, 23 Jun 2026 04:13:17 +0200 Subject: [PATCH] tests.py: consolidate --- code/tests.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/code/tests.py b/code/tests.py index 978c32b..4c92f36 100755 --- a/code/tests.py +++ b/code/tests.py @@ -4,7 +4,7 @@ import json import unittest -from robots import json_to_txt, json_to_table, json_to_htaccess, json_to_nginx, json_to_haproxy, json_to_caddy, json_to_lighttpd +from robots import json_to_txt, json_to_table, json_to_htaccess, json_to_nginx, json_to_haproxy, json_to_caddy, json_to_lighttpd, consolidate, default_values, default_value class RobotsUnittestExtensions: def loadJson(self, pathname): @@ -97,6 +97,22 @@ class TestLighttpdConfigGeneration(unittest.TestCase, RobotsUnittestExtensions): self.assertEqualsFile("test_files/lighttpd-block-ai-bots.conf", robots_lighttpd) +class TestConsolidate(unittest.TestCase, RobotsUnittestExtensions): + maxDiff = 8192 + + def test_new_item(self): + existing = {} + self.assertEqual("George Jetson", consolidate(existing, "rosie", "operator", "George Jetson")) + + def test_ignores_defaults(self): + existing = {"rosie": { "operator": "George Jetson"}} + self.assertEqual("George Jetson", consolidate(existing, "rosie", "operator", default_value)) + + def test_new_description(self): + existing = {"rosie": { "description": default_value}} + self.assertEqual("Rosie is the robot maid from The Jetsons, an American animated sitcom.", + consolidate(existing, "rosie", "description", "Rosie is the robot maid from The Jetsons, an American animated sitcom") + if __name__ == "__main__": import os os.chdir(os.path.dirname(__file__))