
    b                         d Z ddlZddlZddlmZ ddlmZmZmZmZm	Z	m
Z
 ddlZd Z G d dej        j                  ZdS )zTests for samba.kcc.graph_utils    N)
GraphError)verify_graph_completeverify_graph_connected*verify_graph_connected_under_edge_failuresverify_graph_forest,verify_graph_connected_under_vertex_failuresverify_graph_no_lonely_verticesc                 4   t          |           dk     rdS t          |           }t                      }t                      }|                    |                                           |                    |                                           |                    t	          |                     |rX|                                }|                                }||f}|                    |           |                    |           |Xt	          |          S )N    )lensetaddpoptupleupdate)vertices	remainingusededgesvwes          =/usr/lib/python3/dist-packages/samba/tests/kcc/graph_utils.py	make_treer   #   s    
8}}qrHI55DEEEHHY]]__HHY]]__	IIeDkk
 MMOOHHJJF		!A   <<    c                   T     e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Z xZS )UndirectedGraphTestsc                    t          t          |                                            t          d          }t          d          }t          t	          j        |d                    }t          t	          j        |d                    }t          t          |dd          |d d                             }||d         |d         fgz   }t          |          }t          |          }|||g| _	        ||z   ||z   ||z   g| _
        |||z   |g| _        |||g| _        |||g| _        |||g| _        ||z   ||z   ||z   g| _        d|df| _        d S )Nabcdefghijkr      r   r   )superr   setUpr   	itertoolscombinationslistzipr   complete_graphdisconnected_clustersgraph_with_unreachablesringlinetreeforestunconnected_graph)
selfr   	vertices2r   edges2
line_edges
ring_edgesr/   tree2	__class__s
            r   r%   zUndirectedGraphTests.setUp9   st   "D))//111$$%LL	i,Xq99::y-i;;<<#hqrrlHSbSM::;;
HQK"#>"??
"")$$$h9&+fn&.&:&.&:&<" ).(09(<(0(2$  84	84	8X.	e|)+)+- #%h!3r   c                 *     | j         t          |g|R  S N)assertRaisesr   )r2   fnargss      r   assertGraphErrorz%UndirectedGraphTests.assertGraphErrorY   s     t R7$7777r   c                     t           } | j        |g| j        R    | j        |g| j        R    | j        |g| j        R    | j        |g| j        R   |                      || j                    d S r:   )r   r>   r+   r,   r-   r/   assertIsNoner*   r2   r<   s     r   test_graph_completez(UndirectedGraphTests.test_graph_complete\   s    "b>4#=>>>>b@4#?@@@@b-49----b-49----""d1233333r   c                    t           } | j        |g| j        R    | j        |g| j        R    | j        |g| j        R    | j        |g| j        R   |                      || j                    |                      || j                    |                      || j	                    |                      || j
                    d S r:   )r   r>   r+   r,   r0   r1   r@   r.   r-   r*   r/   rA   s     r   test_graph_connectedz)UndirectedGraphTests.test_graph_connectedf   s    #b>4#=>>>>b@4#?@@@@b/4;////b:4#9::::""di.)))""di.)))""d12333""di.)))))r   c                 n   t           } | j        |g| j        R    | j        |g| j        R    | j        |g| j        R   |                      || j                    |                      || j                    |                      || j                    |                      || j	                    d S r:   )
r   r>   r+   r,   r-   r@   r.   r/   r0   r1   rA   s     r   test_graph_forestz&UndirectedGraphTests.test_graph_forests   s     b>4#=>>>>b@4#?@@@@b-49----""di.)))""di.)))""dk*+++""d4566666r   c                     t           } | j        |g| j        R    | j        |g| j        R    | j        |g| j        R    | j        |g| j        R   |                      || j                    |                      || j                    d S r:   )	r   r>   r.   r/   r0   r+   r@   r-   r*   rA   s     r   (test_graph_connected_under_edge_failuresz=UndirectedGraphTests.test_graph_connected_under_edge_failures   s    7b-49----b-49----b/4;////b>4#=>>>>""di.)))""d1233333r   c                     t           } | j        |g| j        R    | j        |g| j        R    | j        |g| j        R    | j        |g| j        R   |                      || j                    |                      || j                    d S r:   )	r   r>   r.   r/   r0   r+   r@   r-   r*   rA   s     r   *test_graph_connected_under_vertex_failuresz?UndirectedGraphTests.test_graph_connected_under_vertex_failures   s    9b-49----b-49----b/4;////b>4#=>>>>""di.)))""d1233333r   c                     d S r:   r   r2   s    r   test_graph_multi_edge_forestz1UndirectedGraphTests.test_graph_multi_edge_forest       r   c                    t           } | j        |g| j        R    | j        |g| j        R   |                      || j                    |                      || j                    |                      || j                    |                      || j                    |                      || j	                    d S r:   )
r	   r>   r1   r,   r@   r-   r*   r.   r/   r0   rA   s     r   test_graph_no_lonely_verticesz2UndirectedGraphTests.test_graph_no_lonely_vertices   s    ,b:4#9::::b@4#?@@@@""di.)))""d12333""di.)))""di.)))""dk*+++++r   c                     d S r:   r   rL   s    r   test_graph_no_unknown_verticesz3UndirectedGraphTests.test_graph_no_unknown_vertices   rN   r   )__name__
__module____qualname__r%   r>   rB   rD   rF   rH   rJ   rM   rP   rR   __classcell__)r8   s   @r   r   r   7   s        4 4 4 4 4@8 8 84 4 4* * *
7 
7 
7	4 	4 	4
4 
4 
4  	, 	, 	,      r   r   )__doc__sambasamba.testssamba.kcc.graph_utilsr   r   r   r   r   r   r	   r&   r   testsTestCaser   r   r   r   <module>r]      s   ( & %      , , , , , ,D D D D D D D D D D D D D D D D      (n n n n n5;/ n n n n nr   