def test_deserialize_solid_def_snaps_enum(): @solid(config_schema=Field( Enum("CowboyType", [EnumValue("good"), EnumValue("bad"), EnumValue("ugly")]))) def noop_solid(_): pass @pipeline def noop_pipeline(): noop_solid() pipeline_snapshot = PipelineSnapshot.from_pipeline_def(noop_pipeline) solid_def_snap = pipeline_snapshot.get_node_def_snap("noop_solid") recevied_config_type = pipeline_snapshot.get_config_type_from_solid_def_snap( solid_def_snap) assert isinstance(recevied_config_type, Enum) assert recevied_config_type.given_name == "CowboyType" assert all(enum_value.config_value in ("good", "bad", "ugly") for enum_value in recevied_config_type.enum_values)
def test_deserialize_solid_def_snaps_multi_type_config(snapshot): @solid(config=Field( Permissive({ 'foo': Field(Array(float)), 'bar': Selector({ 'baz': Field(Noneable(int)), 'qux': { 'quux': Field(str), 'corge': Field( Enum( 'RGB', [ EnumValue('red'), EnumValue('green'), EnumValue('blue') ], )), }, }), }))) def fancy_solid(_): pass @pipeline def noop_pipeline(): fancy_solid() pipeline_snapshot = PipelineSnapshot.from_pipeline_def(noop_pipeline) solid_def_snap = pipeline_snapshot.get_solid_def_snap('fancy_solid') recevied_config_type = pipeline_snapshot.get_config_type_from_solid_def_snap( solid_def_snap) snapshot.assert_match( serialize_pp(snap_from_config_type(recevied_config_type))) _map_has_stable_hashes( recevied_config_type, pipeline_snapshot.config_schema_snapshot.all_config_snaps_by_key)
def test_deserialize_solid_def_snaps_multi_type_config(snapshot): @solid(config_schema=Field( Permissive({ "foo": Field(Array(float)), "bar": Selector({ "baz": Field(Noneable(int)), "qux": { "quux": Field(str), "corge": Field( Enum( "RGB", [ EnumValue("red"), EnumValue("green"), EnumValue("blue") ], )), }, }), }))) def fancy_solid(_): pass @pipeline def noop_pipeline(): fancy_solid() pipeline_snapshot = PipelineSnapshot.from_pipeline_def(noop_pipeline) solid_def_snap = pipeline_snapshot.get_solid_def_snap("fancy_solid") recevied_config_type = pipeline_snapshot.get_config_type_from_solid_def_snap( solid_def_snap) snapshot.assert_match( serialize_pp(snap_from_config_type(recevied_config_type))) _map_has_stable_hashes( recevied_config_type, pipeline_snapshot.config_schema_snapshot.all_config_snaps_by_key)
def test_deserialize_solid_def_snaps_enum(): @solid( config_schema=Field( Enum('CowboyType', [EnumValue('good'), EnumValue('bad'), EnumValue('ugly')]) ) ) def noop_solid(_): pass @pipeline def noop_pipeline(): noop_solid() pipeline_snapshot = PipelineSnapshot.from_pipeline_def(noop_pipeline) solid_def_snap = pipeline_snapshot.get_solid_def_snap('noop_solid') recevied_config_type = pipeline_snapshot.get_config_type_from_solid_def_snap(solid_def_snap) assert isinstance(recevied_config_type, Enum) assert recevied_config_type.given_name == 'CowboyType' assert all( enum_value.config_value in ('good', 'bad', 'ugly') for enum_value in recevied_config_type.enum_values )