| 1 |  |  | import networkx as nx | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | from graphinate.renderers.matplotlib import draw | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | # Drawing a graph with default parameters (node labels on, edge labels off) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | def test_draw_with_default_parameters(mocker): | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     # Arrange | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     mock_nx_draw = mocker.patch('networkx.draw') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     mock_nx_draw_edge_labels = mocker.patch('networkx.draw_networkx_edge_labels') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     mock_spring_layout = mocker.patch('networkx.spring_layout', return_value='mock_pos') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     mock_is_planar = mocker.patch('networkx.is_planar', return_value=False) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     mock_node_color_mapping = mocker.patch('graphinate.renderers.matplotlib.node_color_mapping', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |                                            return_value={0: 'red', 1: 'blue'}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     graph = nx.Graph() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     graph.add_node(0, label='Node0') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     graph.add_node(1, label='Node1') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     graph.add_edge(0, 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     # Act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     draw(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     # Assert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     mock_is_planar.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     mock_spring_layout.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     mock_node_color_mapping.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     mock_nx_draw.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     mock_nx_draw_edge_labels.assert_not_called() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | # Drawing a graph with node labels turned off | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 33 |  | View Code Duplication | def test_draw_with_node_labels_off(mocker): | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     # Arrange | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     mock_nx_draw = mocker.patch('networkx.draw') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     mock_spring_layout = mocker.patch('networkx.spring_layout', return_value='mock_pos') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     mock_is_planar = mocker.patch('networkx.is_planar', return_value=False) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     mock_node_color_mapping = mocker.patch('graphinate.renderers.matplotlib.node_color_mapping', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |                                            return_value={0: 'red', 1: 'blue'}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     graph = nx.Graph() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     graph.add_node(0, label='Node0') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     graph.add_node(1, label='Node1') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     graph.add_edge(0, 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     # Act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     draw(graph, with_node_labels=False) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     # Assert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     mock_is_planar.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     mock_spring_layout.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     mock_node_color_mapping.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     mock_nx_draw.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     # Check that 'with_labels' is not in the draw parameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     args, kwargs = mock_nx_draw.call_args | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     assert 'with_labels' not in kwargs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | # Drawing a graph with edge labels turned on | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 60 |  | View Code Duplication | def test_draw_with_edge_labels_on(mocker): | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     # Arrange | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     mock_nx_draw = mocker.patch('networkx.draw') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     mock_nx_draw_edge_labels = mocker.patch('networkx.draw_networkx_edge_labels') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     mock_spring_layout = mocker.patch('networkx.spring_layout', return_value='mock_pos') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     mock_is_planar = mocker.patch('networkx.is_planar', return_value=False) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     mock_node_color_mapping = mocker.patch('graphinate.renderers.matplotlib.node_color_mapping', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                                            return_value={0: 'red', 1: 'blue'}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     graph = nx.Graph() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     graph.add_node(0, label='Node0') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     graph.add_node(1, label='Node1') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     graph.add_edge(0, 1, label='Edge0-1') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     # Act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     draw(graph, with_edge_labels=True) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     # Assert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     mock_is_planar.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     mock_spring_layout.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     mock_node_color_mapping.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     mock_nx_draw.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     mock_nx_draw_edge_labels.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | # Drawing a graph with both node and edge labels turned on | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 86 |  | View Code Duplication | def test_draw_with_both_labels_on(mocker): | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     # Arrange | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     mock_nx_draw = mocker.patch('networkx.draw') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     mock_nx_draw_edge_labels = mocker.patch('networkx.draw_networkx_edge_labels') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     mock_spring_layout = mocker.patch('networkx.spring_layout', return_value='mock_pos') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     mock_is_planar = mocker.patch('networkx.is_planar', return_value=False) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     mock_node_color_mapping = mocker.patch('graphinate.renderers.matplotlib.node_color_mapping', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                                            return_value={0: 'red', 1: 'blue'}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     graph = nx.Graph() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     graph.add_node(0, label='Node0') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     graph.add_node(1, label='Node1') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     graph.add_edge(0, 1, label='Edge0-1') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     # Act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     draw(graph, with_node_labels=True, with_edge_labels=True) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     # Assert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     mock_is_planar.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     mock_spring_layout.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     mock_node_color_mapping.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     mock_nx_draw.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     mock_nx_draw_edge_labels.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     # Check that node labels are enabled | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     args, kwargs = mock_nx_draw.call_args | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     assert kwargs.get('with_labels') is True | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | # Drawing a planar graph uses planar_layout first | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 116 |  | View Code Duplication | def test_draw_planar_graph(mocker): | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     # Arrange | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     mock_nx_draw = mocker.patch('networkx.draw') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     mock_planar_layout = mocker.patch('networkx.planar_layout', return_value='planar_pos') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     mock_spring_layout = mocker.patch('networkx.spring_layout', return_value='spring_pos') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     mock_is_planar = mocker.patch('networkx.is_planar', return_value=True) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     mock_node_color_mapping = mocker.patch('graphinate.renderers.matplotlib.node_color_mapping', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |                                            return_value={0: 'red', 1: 'blue'}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     graph = nx.Graph() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     graph.add_node(0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     graph.add_node(1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     graph.add_edge(0, 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     # Act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     draw(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     # Assert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     mock_is_planar.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     mock_planar_layout.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     mock_spring_layout.assert_called_once_with(graph, pos='planar_pos') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     mock_node_color_mapping.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     mock_nx_draw.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 141 |  |  | # Drawing a non-planar graph uses spring_layout directly | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 142 |  | View Code Duplication | def test_draw_non_planar_graph(mocker): | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |     # Arrange | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |     mock_nx_draw = mocker.patch('networkx.draw') | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |     mock_planar_layout = mocker.patch('networkx.planar_layout') | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |     mock_spring_layout = mocker.patch('networkx.spring_layout', return_value='spring_pos') | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  |     mock_is_planar = mocker.patch('networkx.is_planar', return_value=False) | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |     mock_node_color_mapping = mocker.patch('graphinate.renderers.matplotlib.node_color_mapping', | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |                                            return_value={0: 'red', 1: 'blue'}) | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  |     graph = nx.Graph() | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |     graph.add_node(0) | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  |     graph.add_node(1) | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |     graph.add_edge(0, 1) | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  |     # Act | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  |     draw(graph) | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |     # Assert | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  |     mock_is_planar.assert_called_once_with(graph) | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |     mock_planar_layout.assert_not_called() | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |     mock_spring_layout.assert_called_once_with(graph) | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  |     mock_node_color_mapping.assert_called_once_with(graph) | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |     mock_nx_draw.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | # Drawing an empty graph | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | def test_draw_empty_graph(mocker): | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     # Arrange | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     mock_nx_draw = mocker.patch('networkx.draw') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     mock_spring_layout = mocker.patch('networkx.spring_layout', return_value={}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     mock_is_planar = mocker.patch('networkx.is_planar', return_value=True) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     mock_node_color_mapping = mocker.patch('graphinate.renderers.matplotlib.node_color_mapping', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |                                            return_value={}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |     graph = nx.Graph() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     # Act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     draw(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     # Assert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     mock_is_planar.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |     mock_spring_layout.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |     mock_node_color_mapping.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     mock_nx_draw.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     # Check that node_color is an empty list for empty graph | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     args, kwargs = mock_nx_draw.call_args | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     assert kwargs.get('node_color') == [] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | # Drawing a graph with no node attributes for labels when with_node_labels=True | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 193 |  | View Code Duplication | def test_draw_no_node_labels_attribute(mocker): | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     # Arrange | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     mock_nx_draw = mocker.patch('networkx.draw') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     mock_get_node_attributes = mocker.patch('networkx.get_node_attributes', return_value={}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     mock_spring_layout = mocker.patch('networkx.spring_layout', return_value='mock_pos') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |     mock_is_planar = mocker.patch('networkx.is_planar', return_value=False) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |     mock_node_color_mapping = mocker.patch('graphinate.renderers.matplotlib.node_color_mapping', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |                                            return_value={0: 'red', 1: 'blue'}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     graph = nx.Graph() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     graph.add_node(0)  # No label attribute | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     graph.add_node(1)  # No label attribute | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |     graph.add_edge(0, 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     # Act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     draw(graph, with_node_labels=True) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     # Assert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     mock_is_planar.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     mock_spring_layout.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |     mock_node_color_mapping.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     mock_get_node_attributes.assert_called_once_with(graph, 'label') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |     mock_nx_draw.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     # Check that labels parameter is empty dict | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     args, kwargs = mock_nx_draw.call_args | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     assert kwargs.get('labels') == {} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | # Drawing a graph with no edge attributes for labels when with_edge_labels=True | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 223 |  | View Code Duplication | def test_draw_no_edge_labels_attribute(mocker): | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     # Arrange | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     mock_nx_draw = mocker.patch('networkx.draw') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |     mock_nx_draw_edge_labels = mocker.patch('networkx.draw_networkx_edge_labels') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     mock_get_edge_attributes = mocker.patch('networkx.get_edge_attributes', return_value={}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |     mock_spring_layout = mocker.patch('networkx.spring_layout', return_value='mock_pos') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     mock_is_planar = mocker.patch('networkx.is_planar', return_value=False) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |     mock_node_color_mapping = mocker.patch('graphinate.renderers.matplotlib.node_color_mapping', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                                            return_value={0: 'red', 1: 'blue'}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     graph = nx.Graph() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     graph.add_node(0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     graph.add_node(1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     graph.add_edge(0, 1)  # No label attribute | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |     # Act | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     draw(graph, with_edge_labels=True) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |     # Assert | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |     mock_is_planar.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     mock_spring_layout.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     mock_node_color_mapping.assert_called_once_with(graph) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |     mock_get_edge_attributes.assert_called_once_with(graph, 'label') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |     mock_nx_draw.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |     mock_nx_draw_edge_labels.assert_called_once() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |     # Check that the edge_labels parameter is an empty dict | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |     args, kwargs = mock_nx_draw_edge_labels.call_args | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 251 |  |  |     assert kwargs.get('edge_labels') == {} | 
            
                                                        
            
                                    
            
            
                | 252 |  |  |  |