def test_transform_contains_join_of_lookups_str_and_non_str(runner_class): input_data = [ {"a": "foo a", "b": 1}, {"a": "far a", "b": 2}, {"a": "boo a", "b": 3}, {"a": "bar a", "b": 4}, ] mapping = make_simple_mapping( { "c": [ TransformationEntry( transformation="join(', ', 'bar', a, 5, b, 0)", ) ], }, types={"b": ColumnConversion(type="int")}, ) extractor = FakeConnector(data=input_data) loader = FakeConnector() runner_class(Config()).run(extractor, mapping, loader) assert list(loader.data) == [ {"c": "bar, foo a, 5, 1, 0"}, {"c": "bar, far a, 5, 2, 0"}, {"c": "bar, boo a, 5, 3, 0"}, {"c": "bar, bar a, 5, 4, 0"}, ]
def test_column_is_specified_as_string___values_are_changed_bad_are_excluded( runner_class, ): input_data = [ {"a": "1"}, {"a": 3.1}, {"a": None}, {"a": "NULL"}, {"a": "foo"}, ] mapping = make_simple_mapping( {"b": [TransformationEntry(transformation="a")]}, types={ "a": ColumnConversion(type="string", null_values=[None, "NULL"]), }, ) extractor = FakeConnector(data=input_data) loader = FakeConnector() runner_class(Config()).run(extractor, mapping, loader) assert list(loader.data) == [ {"b": "1"}, {"b": "3.1"}, {"b": None}, {"b": None}, {"b": "foo"}, ]