Coverage for libs/sdc_etl_libs/tests/sdc_data_schema_tests/schema_toolbox_tests/get_field_names_for_file_test.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
2import os
3import sys
4import pytest
5sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../../../../")
6from sdc_etl_libs.sdc_data_schema.schema_toolbox import SchemaToolbox
9def test_determine_dataframe_from_schema_happy_path():
10 """
11 Ensure get_field_names_for_file returns all field names
12 """
14 data_schema = {
15 "fields": [
16 {"name": "COL1", "type": {"type": "string"}},
17 {"name": "COL2", "type": {"type": "string"}},
18 {"name": "COL3", "type": {"type": "string"}},
19 ]
20 }
22 result = SchemaToolbox.get_field_names_for_file(data_schema)
23 assert result == ["COL1", "COL2", "COL3"]
26def test_determine_dataframe_from_schema_added_field_removed():
27 """
28 Ensure a field with "add_column" == True is removed from the list.
29 """
31 data_schema = {
32 "fields": [
33 {"name": "COL1", "type": {"type": "string"}},
34 {"name": "COL2", "type": {"type": "string"}, "add_column": True},
35 {"name": "COL3", "type": {"type": "string"}},
36 ]
37 }
39 result = SchemaToolbox.get_field_names_for_file(data_schema)
40 assert result == ["COL1", "COL3"]