github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/python/tests/unit/sdk/multiobj/test_object_template.py (about) 1 import unittest 2 from unittest.mock import patch 3 4 from aistore.sdk.multiobj import ObjectTemplate 5 6 7 # pylint: disable=unused-variable 8 class TestObjectTemplate(unittest.TestCase): 9 def setUp(self): 10 self.template_str = "prefix-{1..6..2}-gap-{12..14..1}-suffix" 11 self.obj_range_template = ObjectTemplate(self.template_str) 12 13 def test_get_value(self): 14 self.assertEqual( 15 {"template": self.template_str}, self.obj_range_template.get_value() 16 ) 17 18 @patch("aistore.sdk.multiobj.object_template.utils.expand_braces") 19 def test_iter(self, mock_expand): 20 expansion_result = ["mock expansion result", "result2"] 21 mock_expand.return_value.__next__.side_effect = expansion_result 22 self.assertEqual( 23 expansion_result, 24 list(self.obj_range_template), 25 )