Code Duplication    Length = 23-23 lines in 3 locations

tests/graphinate/renderers/test_matplotlib_plot.py 3 locations

@@ 57-79 (lines=23) @@
54
        mock_pyplot.show.assert_called_once()
55
56
    # Plot a graph with neither node nor edge labels displayed
57
    def test_plot_without_node_and_edge_labels(self, mocker):
58
        # Arrange
59
        mock_draw = mocker.patch('graphinate.renderers.matplotlib.draw')
60
        mock_pyplot = mocker.patch('graphinate.renderers.matplotlib.pyplot')
61
        mock_ax = mocker.MagicMock()
62
        mock_fig = mocker.MagicMock()
63
        mock_pyplot.gca.return_value = mock_ax
64
        mock_pyplot.gcf.return_value = mock_fig
65
66
        graph = nx.Graph(name="Test Graph")
67
        graph.add_node(1, label="Node 1")
68
        graph.add_edge(1, 2, label="Edge 1-2")
69
70
        # Act
71
        from graphinate.renderers.matplotlib import plot
72
        plot(graph, with_node_labels=False, with_edge_labels=False)
73
74
        # Assert
75
        mock_draw.assert_called_once_with(graph, False, False)
76
        mock_ax.margins.assert_called_once_with(0.10)
77
        mock_fig.suptitle.assert_called_once_with("Test Graph")
78
        mock_fig.tight_layout.assert_called_once()
79
        mock_pyplot.show.assert_called_once()
80
81
    # Plot a graph with custom kwargs that are passed to the draw function
82
    def test_plot_with_custom_kwargs(self, mocker):
@@ 32-54 (lines=23) @@
29
        mock_pyplot.show.assert_called_once()
30
31
    # Plot a graph with both node and edge labels displayed
32
    def test_plot_with_node_and_edge_labels(self, mocker):
33
        # Arrange
34
        mock_draw = mocker.patch('graphinate.renderers.matplotlib.draw')
35
        mock_pyplot = mocker.patch('graphinate.renderers.matplotlib.pyplot')
36
        mock_ax = mocker.MagicMock()
37
        mock_fig = mocker.MagicMock()
38
        mock_pyplot.gca.return_value = mock_ax
39
        mock_pyplot.gcf.return_value = mock_fig
40
41
        graph = nx.Graph(name="Test Graph")
42
        graph.add_node(1, label="Node 1")
43
        graph.add_edge(1, 2, label="Edge 1-2")
44
45
        # Act
46
        from graphinate.renderers.matplotlib import plot
47
        plot(graph, with_node_labels=True, with_edge_labels=True)
48
49
        # Assert
50
        mock_draw.assert_called_once_with(graph, True, True)
51
        mock_ax.margins.assert_called_once_with(0.10)
52
        mock_fig.suptitle.assert_called_once_with("Test Graph")
53
        mock_fig.tight_layout.assert_called_once()
54
        mock_pyplot.show.assert_called_once()
55
56
    # Plot a graph with neither node nor edge labels displayed
57
    def test_plot_without_node_and_edge_labels(self, mocker):
@@ 7-29 (lines=23) @@
4
class TestPlot:
5
6
    # Plot a simple graph with default parameters (node labels shown, edge labels hidden)
7
    def test_plot_with_default_parameters(self, mocker):
8
        # Arrange
9
        mock_draw = mocker.patch('graphinate.renderers.matplotlib.draw')
10
        mock_pyplot = mocker.patch('graphinate.renderers.matplotlib.pyplot')
11
        mock_ax = mocker.MagicMock()
12
        mock_fig = mocker.MagicMock()
13
        mock_pyplot.gca.return_value = mock_ax
14
        mock_pyplot.gcf.return_value = mock_fig
15
16
        graph = nx.Graph(name="Test Graph")
17
        graph.add_node(1, label="Node 1")
18
        graph.add_edge(1, 2, label="Edge 1-2")
19
20
        # Act
21
        from graphinate.renderers.matplotlib import plot
22
        plot(graph)
23
24
        # Assert
25
        mock_draw.assert_called_once_with(graph, True, False)
26
        mock_ax.margins.assert_called_once_with(0.10)
27
        mock_fig.suptitle.assert_called_once_with("Test Graph")
28
        mock_fig.tight_layout.assert_called_once()
29
        mock_pyplot.show.assert_called_once()
30
31
    # Plot a graph with both node and edge labels displayed
32
    def test_plot_with_node_and_edge_labels(self, mocker):