From 10194641506a05678c1fe47f172f08fba0d5c455 Mon Sep 17 00:00:00 2001 From: Aldo Mateli Date: Sat, 26 Aug 2023 13:16:54 +0100 Subject: [PATCH] Add bag cache hit test --- test/test_parameter.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test_parameter.py b/test/test_parameter.py index e5d4e9f..c5d8e59 100644 --- a/test/test_parameter.py +++ b/test/test_parameter.py @@ -1,6 +1,6 @@ import unittest -from wireup.ioc.container_util import ParameterWrapper +from wireup.ioc.container_util import ParameterWrapper, ParameterReference from wireup.ioc.parameter import ParameterBag, TemplatedString @@ -44,6 +44,12 @@ def test_all(self): self.assertEqual(self.bag.get_all(), {"foo": "bar", "bar": "baz", "baz": "qux"}) + def test_parameter_interpolation_is_cached(self): + self.bag.put("foo", "bar") + self.assertEqual(self.bag.get(TemplatedString("${foo}-${foo}")), "bar-bar") + self.assertEqual(self.bag.get(TemplatedString("${foo}-${foo}")), "bar-bar") + self.assertEqual(self.bag._ParameterBag__cache, {"${foo}-${foo}": "bar-bar"}) # noqa: SLF001 + class TestParameterPlaceholder(unittest.TestCase): def test_init(self):