<s> from __future__ import print_function <EOL> from BroControl . state import SqliteState <EOL> def test_state_basic ( ) : <EOL> s = SqliteState ( "<STR_LIT>" ) <EOL> assert s . get ( "<STR_LIT:key>" ) == None <EOL> s . set ( "<STR_LIT:key>" , "<STR_LIT:value>" ) <EOL> assert s . get ( "<STR_LIT:key>" ) == "<STR_LIT:value>" <EOL> s . set ( "<STR_LIT:int>" , <NUM_LIT> ) <EOL> assert s . get ( "<STR_LIT:int>" ) == <NUM_LIT> <EOL> s . set ( "<STR_LIT:bool>" , False ) <EOL> assert s . get ( "<STR_LIT:bool>" ) == False <EOL> def test_state_update ( ) : <EOL> s = SqliteState ( "<STR_LIT>" ) <EOL> s . set ( "<STR_LIT:key>" , "<STR_LIT:value>" ) <EOL> assert s . get ( "<STR_LIT:key>" ) == "<STR_LIT:value>" <EOL> s . set ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> assert s . get ( "<STR_LIT:key>" ) == "<STR_LIT>" <EOL> def test_state_setdefault ( ) : <EOL> s = SqliteState ( "<STR_LIT>" ) <EOL> s . set ( "<STR_LIT:key>" , "<STR_LIT:value>" ) <EOL> assert s . get ( "<STR_LIT:key>" ) == "<STR_LIT:value>" <EOL> s . setdefault ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> assert s . get ( "<STR_LIT:key>" ) == "<STR_LIT:value>" <EOL> def test_state_items ( ) : <EOL> s = SqliteState ( "<STR_LIT>" ) <EOL> s . set ( "<STR_LIT:a>" , <NUM_LIT:1> ) <EOL> s . set ( "<STR_LIT:b>" , "<STR_LIT>" ) <EOL> d = dict ( s . items ( ) ) <EOL> print ( d ) <EOL> assert d [ "<STR_LIT:a>" ] == <NUM_LIT:1> <EOL> assert d [ "<STR_LIT:b>" ] == "<STR_LIT>" </s>
