コード例 #1
0
ファイル: test_asciigraf.py プロジェクト: yangineer/asciigraf
def test_ascii_positions():
    graph = graph_from_ascii("""
                Node_1---Node2-----
                                 /
                               Nald33
        """)
    assert graph.node["Node_1"]["position"] == Point(x=16, y=1)
    assert graph.node["Node2"]["position"] == Point(x=25, y=1)
    assert graph.node["Nald33"]["position"] == Point(x=31, y=3)
コード例 #2
0
def test_get_edge_chars_with_vertical_label():
    assert get_edge_chars("""
        |
        |
      (label)
        |
        |
    """) == {
        Point(8, 1): "|",
        Point(8, 2): "|",
        Point(8, 4): "|",
        Point(8, 5): "|",
    }
コード例 #3
0
ファイル: test_asciigraf.py プロジェクト: yangineer/asciigraf
def test_node_iter_returns_label_and_position_of_nodes():
    network = """
    Sa---1
        /
       |---L_245
    """

    nodes = dict(node_iter(network))

    assert len(nodes) == 3
    assert nodes["Sa"] == Point(4, 1)
    assert nodes["L_245"] == Point(11, 3)
    assert nodes["1"] == Point(9, 1)
コード例 #4
0
def test_patching_edge_chars_over_vertical_label():
    edge_chars = get_edge_chars("""
        |
        |
      (label)
        |
        |""")
    labels = {Point(6, 3): "(label)"}
    edge_chars = patch_edge_chars_over_labels(labels, edge_chars)

    assert draw(edge_chars) == """
コード例 #5
0
def test_get_edge_chars_with_horizontal_label():
    assert get_edge_chars("---(label)---") == {
        Point(0, 0): "-",
        Point(1, 0): "-",
        Point(2, 0): "-",
        Point(10, 0): "-",
        Point(11, 0): "-",
        Point(12, 0): "-",
    }
コード例 #6
0
def p12():
    return Point(1, 2)
コード例 #7
0
def test_points_with_same_coords_are_equal(p12):
    assert p12 == Point(1, 2)
コード例 #8
0
def test_sorting_commutes():
    assert Point(33, 2) > Point(34, 1)
    assert Point(34, 1) < Point(33, 2)
    assert not Point(33, 2) < Point(34, 1)
    assert not Point(34, 1) > Point(33, 2)
コード例 #9
0
def test_points_are_sortable():
    starting_list = [Point(1, 2), Point(2, 1), Point(1, 1)]
    sorted_list = sorted(starting_list)
    assert sorted_list == [Point(1, 1), Point(2, 1), Point(1, 2)]
コード例 #10
0
def test_points_compare():
    assert Point(1, 1) < Point(1, 2)
    assert Point(1, 1) < Point(2, 1)
コード例 #11
0
def p34():
    return Point(3, 4)
コード例 #12
0
def test_drawing_nodes_and_edge_chars():
    assert draw(edge_chars={
        Point(8, 1): "|",
        Point(8, 2): "|",
        Point(8, 4): "|",
        Point(8, 5): "|",
    },
                nodes={
                    Point(8, 3): "my_node",
                    Point(12, 3): "my_node",
                    Point(7, 3): "my_node",
                    Point(9, 3): "my_node",
                    Point(10, 3): "my_node",
                    Point(6, 3): "my_node",
                    Point(11, 3): "my_node",
                }) == """
コード例 #13
0
def test_patching_edge_chars_over_horizontal_label():
    edge_chars = get_edge_chars("---(label)---")
    labels = {Point(3, 0): "(label)"}
    edge_chars = patch_edge_chars_over_labels(labels, edge_chars)

    assert draw(edge_chars) == "-------------"
コード例 #14
0
def test_get_edge_chars():
    assert get_edge_chars("   --|   ") == {
        Point(3, 0): "-",
        Point(4, 0): "-",
        Point(5, 0): "|",
    }