<s> import unittest <EOL> from bubbles import * <EOL> class GraphTestCase ( unittest . TestCase ) : <EOL> def test_basic ( self ) : <EOL> g = Graph ( ) <EOL> g . add ( Node ( "<STR_LIT:src>" ) , "<STR_LIT>" ) <EOL> g . add ( Node ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> g . add ( Node ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:3> , len ( g . nodes ) ) <EOL> g . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> sources = g . sources ( "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( sources ) ) <EOL> self . assertTrue ( isinstance ( sources [ "<STR_LIT:default>" ] , Node ) ) <EOL> self . assertEqual ( "<STR_LIT:src>" , sources [ "<STR_LIT:default>" ] . opname ) <EOL> def test_ports ( self ) : <EOL> g = Graph ( ) <EOL> g . add ( Node ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> g . add ( Node ( "<STR_LIT:src>" ) , "<STR_LIT:src>" ) <EOL> g . add ( Node ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> g . connect ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> with self . assertRaises ( GraphError ) : <EOL> g . connect ( "<STR_LIT:src>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> g . connect ( "<STR_LIT:src>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> sources = g . sources ( "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( sources ) ) <EOL> self . assertEqual ( [ "<STR_LIT>" , "<STR_LIT>" ] , sorted ( sources . keys ( ) ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
