<s> import os <EOL> import sys <EOL> import unittest <EOL> sys . path . append ( os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT>" ) ) <EOL> from conversation_table import ConversationTable <EOL> class StubConversation ( object ) : <EOL> pass <EOL> class TestConversationTable ( unittest . TestCase ) : <EOL> def test_add_get ( self ) : <EOL> table = ConversationTable ( ) <EOL> conversation = StubConversation ( ) <EOL> table . add_conversation ( "<STR_LIT:127.0.0.1>" , "<STR_LIT>" , conversation ) <EOL> self . assertEqual ( table . get_conversation ( "<STR_LIT:127.0.0.1>" , "<STR_LIT>" ) , <EOL> conversation ) <EOL> self . assertTrue ( table . lock . _RLock__count == <NUM_LIT:0> ) <EOL> def test_get_without_add ( self ) : <EOL> table = ConversationTable ( ) <EOL> self . assertIsNone ( table . get_conversation ( "<STR_LIT:127.0.0.1>" , "<STR_LIT>" ) ) <EOL> self . assertTrue ( table . lock . _RLock__count == <NUM_LIT:0> ) <EOL> def test_add_delete ( self ) : <EOL> table = ConversationTable ( ) <EOL> conversation = StubConversation ( ) <EOL> table . add_conversation ( "<STR_LIT:127.0.0.1>" , "<STR_LIT>" , conversation ) <EOL> self . assertTrue ( table . delete_conversation ( "<STR_LIT:127.0.0.1>" , "<STR_LIT>" ) ) <EOL> self . assertIsNone ( table . get_conversation ( "<STR_LIT:127.0.0.1>" , "<STR_LIT>" ) ) <EOL> self . assertTrue ( table . lock . _RLock__count == <NUM_LIT:0> ) <EOL> def test_delete_without_add ( self ) : <EOL> table = ConversationTable ( ) <EOL> self . assertEqual ( table . delete_conversation ( "<STR_LIT:127.0.0.1>" , "<STR_LIT>" ) , <EOL> False ) <EOL> self . assertIsNone ( table . get_conversation ( "<STR_LIT:127.0.0.1>" , "<STR_LIT>" ) ) <EOL> self . assertTrue ( table . lock . _RLock__count == <NUM_LIT:0> ) <EOL> def test_conversations ( self ) : <EOL> table = ConversationTable ( ) <EOL> conversation_one = StubConversation ( ) <EOL> table . add_conversation ( "<STR_LIT>" , "<STR_LIT>" , conversation_one ) <EOL> conversation_two = StubConversation ( ) <EOL> table . add_conversation ( "<STR_LIT>" , "<STR_LIT>" , conversation_two ) <EOL> self . assertTrue ( <EOL> table . conversations == [ conversation_one , conversation_two ] <EOL> or table . conversations == [ conversation_two , conversation_one ] , <EOL> "<STR_LIT>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
