@@ -44,11 +44,7 @@ def test_get_properties_from_endpoint():
4444 parameters = {},
4545 )
4646
47- properties = list (
48- properties_from_endpoint .get_properties_from_endpoint (
49- stream_slice = StreamSlice (cursor_slice = {}, partition = {})
50- )
51- )
47+ properties = properties_from_endpoint .get_properties_from_endpoint (stream_slice = StreamSlice (cursor_slice = {}, partition = {}))
5248
5349 assert len (properties ) == 9
5450 assert properties == expected_properties
@@ -89,11 +85,7 @@ def test_get_properties_from_endpoint_with_multiple_field_paths():
8985 parameters = {},
9086 )
9187
92- properties = list (
93- properties_from_endpoint .get_properties_from_endpoint (
94- stream_slice = StreamSlice (cursor_slice = {}, partition = {})
95- )
96- )
88+ properties = properties_from_endpoint .get_properties_from_endpoint (stream_slice = StreamSlice (cursor_slice = {}, partition = {}))
9789
9890 assert len (properties ) == 9
9991 assert properties == expected_properties
@@ -135,11 +127,51 @@ def test_get_properties_from_endpoint_with_interpolation():
135127 parameters = {},
136128 )
137129
138- properties = list (
139- properties_from_endpoint .get_properties_from_endpoint (
140- stream_slice = StreamSlice (cursor_slice = {}, partition = {})
141- )
142- )
130+ properties = properties_from_endpoint .get_properties_from_endpoint (stream_slice = StreamSlice (cursor_slice = {}, partition = {}))
143131
144132 assert len (properties ) == 9
145133 assert properties == expected_properties
134+
135+
136+ def test_given_multiple_calls_when_get_properties_from_endpoint_then_only_call_retriever_once ():
137+ retriever = Mock (spec = SimpleRetriever )
138+ retriever .read_records .return_value = iter (
139+ [
140+ Record (stream_name = "players" , data = {"id" : "ace" , "value" : 1 }),
141+ ]
142+ )
143+
144+ properties_from_endpoint = PropertiesFromEndpoint (
145+ retriever = retriever ,
146+ property_field_path = ["value" ],
147+ config = {},
148+ parameters = {},
149+ )
150+
151+ properties_from_endpoint .get_properties_from_endpoint (stream_slice = StreamSlice (cursor_slice = {}, partition = {}))
152+ properties_from_endpoint .get_properties_from_endpoint (stream_slice = StreamSlice (cursor_slice = {}, partition = {}))
153+ properties_from_endpoint .get_properties_from_endpoint (stream_slice = StreamSlice (cursor_slice = {}, partition = {}))
154+
155+ assert retriever .read_records .call_count == 1
156+
157+
158+ def test_given_value_is_int_when_get_properties_from_endpoint_then_return_str ():
159+ expected_properties = ["1" ]
160+
161+ retriever = Mock (spec = SimpleRetriever )
162+ retriever .read_records .return_value = iter (
163+ [
164+ Record (stream_name = "players" , data = {"id" : "ace" , "value" : 1 }),
165+ ]
166+ )
167+
168+ properties_from_endpoint = PropertiesFromEndpoint (
169+ retriever = retriever ,
170+ property_field_path = ["value" ],
171+ config = {},
172+ parameters = {},
173+ )
174+
175+ properties = properties_from_endpoint .get_properties_from_endpoint (stream_slice = StreamSlice (cursor_slice = {}, partition = {}))
176+
177+ assert properties == expected_properties
0 commit comments