<s> __author__ = '<STR_LIT>' <EOL> import unittest <EOL> from hydro . topology_base import Topology <EOL> class TP ( Topology ) : <EOL> def _submit ( self , params ) : <EOL> return { '<STR_LIT:a>' : <NUM_LIT:1> } <EOL> class TestTopologyBase ( unittest . TestCase ) : <EOL> def test_init ( self ) : <EOL> inst = TP ( ) <EOL> self . assertTrue ( hasattr ( inst , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> self . assertTrue ( hasattr ( inst , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> self . assertTrue ( hasattr ( inst , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> self . assertTrue ( hasattr ( inst , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> self . assertTrue ( hasattr ( inst , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> self . assertTrue ( hasattr ( inst , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> self . assertTrue ( hasattr ( inst , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> def test_submit ( self ) : <EOL> inst = TP ( ) <EOL> res = inst . submit ( { } ) <EOL> self . assertEqual ( res , { '<STR_LIT:a>' : <NUM_LIT:1> } ) <EOL> def test_not_implemented ( self ) : <EOL> class TP2 ( Topology ) : <EOL> pass <EOL> inst = TP2 ( ) <EOL> self . assertRaises ( Exception , inst . submit , { } ) <EOL> def test_topology_caching1 ( self ) : <EOL> class TP2 ( Topology ) : <EOL> def _submit ( self , params ) : <EOL> return { '<STR_LIT:a>' : <NUM_LIT:1> } <EOL> inst = TP2 ( ) <EOL> for x in range ( <NUM_LIT:10> ) : <EOL> inst . submit ( { } ) <EOL> cntr = <NUM_LIT:0> <EOL> for plan in inst . get_execution_plan ( ) : <EOL> if cntr == <NUM_LIT:0> : <EOL> self . assertFalse ( plan . metadata [ '<STR_LIT>' ] ) <EOL> else : <EOL> self . assertTrue ( plan . metadata [ '<STR_LIT>' ] ) <EOL> cntr += <NUM_LIT:1> <EOL> def test_topology_caching2 ( self ) : <EOL> class TP2 ( Topology ) : <EOL> def _submit ( self , params ) : <EOL> return { '<STR_LIT:a>' : <NUM_LIT:1> } <EOL> inst = TP2 ( ) <EOL> for x in range ( <NUM_LIT:10> ) : <EOL> inst . submit ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> cntr = <NUM_LIT:0> <EOL> for plan in inst . get_execution_plan ( ) : <EOL> if cntr == <NUM_LIT:0> : <EOL> self . assertFalse ( plan . metadata [ '<STR_LIT>' ] ) <EOL> else : <EOL> self . assertTrue ( plan . metadata [ '<STR_LIT>' ] ) <EOL> cntr += <NUM_LIT:1> <EOL> def test_topology_caching3 ( self ) : <EOL> class TP2 ( Topology ) : <EOL> def _submit ( self , params ) : <EOL> return { '<STR_LIT:a>' : <NUM_LIT:1> } <EOL> inst = TP2 ( ) <EOL> for x in range ( <NUM_LIT:10> ) : <EOL> inst . submit ( { '<STR_LIT>' : '<STR_LIT>' + str ( x ) } ) <EOL> for plan in inst . get_execution_plan ( ) : <EOL> self . assertFalse ( plan . metadata [ '<STR_LIT>' ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
