Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lazebnyi committed Dec 16, 2024
1 parent 6976fc7 commit 62dc10c
Showing 1 changed file with 77 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2195,9 +2195,10 @@ def test_remove_fields(self):
)

assert isinstance(stream, DeclarativeStream)
expected = [
RemoveFields(field_pointers=[["path", "to", "field1"], ["path2"]], parameters={})
]
expected = (
[RemoveFields(field_pointers=[["path", "to", "field1"], ["path2"]], parameters={})] * 2
) # Entity will be present twice as we resolve parameters and add the component to both the record
# selector level and the stream level
assert stream.retriever.record_selector.transformations == expected

def test_add_fields_no_value_type(self):
Expand All @@ -2212,21 +2213,25 @@ def test_add_fields_no_value_type(self):
- path: ["field1"]
value: "static_value"
"""
expected = [
AddFields(
fields=[
AddedFieldDefinition(
path=["field1"],
value=InterpolatedString(
string="static_value", default="static_value", parameters={}
),
value_type=None,
parameters={},
)
],
parameters={},
)
]
expected = (
[
AddFields(
fields=[
AddedFieldDefinition(
path=["field1"],
value=InterpolatedString(
string="static_value", default="static_value", parameters={}
),
value_type=None,
parameters={},
)
],
parameters={},
)
]
* 2
) # Entity will be present twice as we resolve parameters and add the component to both the record
# selector level and the stream level
self._test_add_fields(content, expected)

def test_add_fields_value_type_is_string(self):
Expand All @@ -2242,21 +2247,25 @@ def test_add_fields_value_type_is_string(self):
value: "static_value"
value_type: string
"""
expected = [
AddFields(
fields=[
AddedFieldDefinition(
path=["field1"],
value=InterpolatedString(
string="static_value", default="static_value", parameters={}
),
value_type=str,
parameters={},
)
],
parameters={},
)
]
expected = (
[
AddFields(
fields=[
AddedFieldDefinition(
path=["field1"],
value=InterpolatedString(
string="static_value", default="static_value", parameters={}
),
value_type=str,
parameters={},
)
],
parameters={},
)
]
* 2
) # Entity will be present twice as we resolve parameters and add the component to both the record
# selector level and the stream level
self._test_add_fields(content, expected)

def test_add_fields_value_type_is_number(self):
Expand All @@ -2272,19 +2281,23 @@ def test_add_fields_value_type_is_number(self):
value: "1"
value_type: number
"""
expected = [
AddFields(
fields=[
AddedFieldDefinition(
path=["field1"],
value=InterpolatedString(string="1", default="1", parameters={}),
value_type=float,
parameters={},
)
],
parameters={},
)
]
expected = (
[
AddFields(
fields=[
AddedFieldDefinition(
path=["field1"],
value=InterpolatedString(string="1", default="1", parameters={}),
value_type=float,
parameters={},
)
],
parameters={},
)
]
* 2
) # Entity will be present twice as we resolve parameters and add the component to both the record
# selector level and the stream level
self._test_add_fields(content, expected)

def test_add_fields_value_type_is_integer(self):
Expand All @@ -2300,19 +2313,23 @@ def test_add_fields_value_type_is_integer(self):
value: "1"
value_type: integer
"""
expected = [
AddFields(
fields=[
AddedFieldDefinition(
path=["field1"],
value=InterpolatedString(string="1", default="1", parameters={}),
value_type=int,
parameters={},
)
],
parameters={},
)
]
expected = (
[
AddFields(
fields=[
AddedFieldDefinition(
path=["field1"],
value=InterpolatedString(string="1", default="1", parameters={}),
value_type=int,
parameters={},
)
],
parameters={},
)
]
* 2
) # Entity will be present twice as we resolve parameters and add the component to both the record
# selector level and the stream level
self._test_add_fields(content, expected)

def test_add_fields_value_type_is_boolean(self):
Expand Down Expand Up @@ -2340,7 +2357,7 @@ def test_add_fields_value_type_is_boolean(self):
],
parameters={},
)
]
] * 2
self._test_add_fields(content, expected)

def _test_add_fields(self, content, expected):
Expand Down

0 comments on commit 62dc10c

Please sign in to comment.