import pytest

from lang_main.pipelines import predefined as pre
from lang_main.types import EntryPoints


def test_build_base_target_feature_pipe():
    pipe = pre.build_base_target_feature_pipe()
    assert pipe.name == 'Target_Feature'
    assert len(pipe.actions) == 5


def test_build_merge_duplicates_pipe():
    pipe = pre.build_merge_duplicates_pipe()
    assert pipe.name == 'Merge_Duplicates'
    assert len(pipe.actions) == 2


def test_build_tk_graph_pipe():
    pipe = pre.build_tk_graph_pipe()
    assert pipe.name == 'Token_Analysis'
    assert len(pipe.actions) == 1


def test_build_tk_graph_post_pipe():
    pipe = pre.build_tk_graph_post_pipe()
    assert pipe.name == 'Graph_Postprocessing'
    assert len(pipe.actions) == 3


def test_build_tk_graph_rescaling_pipe_with_edge_rescaling():
    pipe = pre.build_tk_graph_rescaling_pipe(
        save_result=False,
        exit_point=EntryPoints.TK_GRAPH_ANALYSIS_RESCALED,
        enable_rescaling=True,
    )
    assert pipe.name == 'Graph_Rescaling'
    assert len(pipe.actions) == 2


def test_build_tk_graph_rescaling_pipe_without_edge_rescaling():
    pipe = pre.build_tk_graph_rescaling_pipe(
        save_result=False,
        exit_point=EntryPoints.TK_GRAPH_ANALYSIS_RESCALED,
        enable_rescaling=False,
    )
    assert pipe.name == 'Graph_Rescaling'
    assert len(pipe.actions) == 1


@pytest.mark.parametrize('with_subgraphs', [True, False])
def test_build_tk_graph_render_pipe(with_subgraphs):
    pipe = pre.build_tk_graph_render_pipe(with_subgraphs=with_subgraphs)
    assert pipe.name == 'Graph_Static-Rendering'
    if with_subgraphs:
        assert len(pipe.actions) == 6
    else:
        assert len(pipe.actions) == 4


def test_build_timeline_pipe():
    pipe = pre.build_timeline_pipe()
    assert pipe.name == 'Timeline_Analysis'
    assert len(pipe.actions) == 6
