def test_basic_comp_solid_definition():
    @solid
    def return_one(_):
        return 1

    @solid
    def take_one(_, one):
        return one

    @composite_solid
    def comp_solid():
        take_one(return_one())

    comp_solid_meta = build_composite_solid_def_snap(comp_solid)

    assert isinstance(comp_solid_meta, CompositeSolidDefSnap)
    assert (deserialize_json_to_dagster_namedtuple(
        serialize_dagster_namedtuple(comp_solid_meta)) == comp_solid_meta)

    index = DependencyStructureIndex(comp_solid_meta.dep_structure_snapshot)
    assert index.get_invocation("return_one")
    assert index.get_invocation("take_one")
    assert index.get_upstream_output("take_one",
                                     "one").solid_name == "return_one"
    assert index.get_upstream_output("take_one", "one").output_name == "result"
def test_basic_dep_fan_out(snapshot):
    @solid
    def return_one(_):
        return 1

    @solid(input_defs=[InputDefinition('value', int)])
    def passthrough(_, value):
        return value

    @pipeline
    def single_dep_pipeline():
        return_one_result = return_one()
        passthrough.alias('passone')(return_one_result)
        passthrough.alias('passtwo')(return_one_result)

    dep_structure_snapshot = build_dep_structure_snapshot_from_icontains_solids(
        single_dep_pipeline)
    index = DependencyStructureIndex(dep_structure_snapshot)

    assert index.get_invocation('return_one')
    assert index.get_invocation('passone')
    assert index.get_invocation('passtwo')

    assert index.get_upstream_output('passone', 'value') == OutputHandleSnap(
        'return_one', 'result')
    assert index.get_upstream_output('passtwo', 'value') == OutputHandleSnap(
        'return_one', 'result')

    assert set(index.get_downstream_inputs('return_one', 'result')) == set([
        InputHandle('passthrough', 'passone', 'value'),
        InputHandle('passthrough', 'passtwo', 'value'),
    ])

    assert (deserialize_json_to_dagster_namedtuple(
        serialize_dagster_namedtuple(dep_structure_snapshot)) ==
            dep_structure_snapshot)

    pipeline_snapshot = PipelineSnapshot.from_pipeline_def(single_dep_pipeline)
    assert pipeline_snapshot == serialize_rt(pipeline_snapshot)

    snapshot.assert_match(serialize_pp(pipeline_snapshot))
    snapshot.assert_match(create_pipeline_snapshot_id(pipeline_snapshot))