Skip to content

Commit

Permalink
Add bag cache hit test
Browse files Browse the repository at this point in the history
  • Loading branch information
maldoinc committed Aug 26, 2023
1 parent 476a8a6 commit 1019464
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/test_parameter.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 1019464

Please sign in to comment.