<s> from nose . tools import ok_ , raises <EOL> from linot import config <EOL> from linot . interfaces . line_interface import LineClientP , LineInterface <EOL> class TestLineClientP : <EOL> def setUp ( self ) : <EOL> self . line_cfg = config [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . lineclient = LineClientP ( self . line_cfg [ '<STR_LIT>' ] , <EOL> self . line_cfg [ '<STR_LIT:password>' ] ) <EOL> def test_find_contact_by_id ( self ) : <EOL> contact = self . lineclient . find_contact_by_id ( self . line_cfg [ '<STR_LIT>' ] ) <EOL> ok_ ( contact . id == self . line_cfg [ '<STR_LIT>' ] ) <EOL> @ raises ( ValueError ) <EOL> def test_find_contact_by_id_exception ( self ) : <EOL> self . lineclient . find_contact_by_id ( self . line_cfg [ '<STR_LIT>' ] [ : - <NUM_LIT:2> ] ) <EOL> class TestLineInterface : <EOL> def setUp ( self ) : <EOL> self . line_interface = LineInterface ( ) <EOL> def test_polling_command ( self ) : <EOL> test_str = '<STR_LIT>' <EOL> me = self . line_interface . _client . getProfile ( ) <EOL> me . sendMessage ( test_str ) <EOL> result = self . line_interface . polling_command ( ) <EOL> ok_ ( len ( result ) == <NUM_LIT:1> , result ) <EOL> submitter , msg = result [ <NUM_LIT:0> ] <EOL> ok_ ( submitter . code == me . id , submitter ) <EOL> ok_ ( msg == test_str , <EOL> '<STR_LIT>' . format ( msg , test_str ) ) <EOL> def test_get_contact_by_id ( self ) : <EOL> me = self . line_interface . _client . getProfile ( ) <EOL> contact = self . line_interface . _get_contact_by_id ( me . id ) <EOL> ok_ ( me . id == contact . id , '<STR_LIT>' . format ( me . id , contact . id ) ) <EOL> def test_send_message ( self ) : <EOL> test_str = '<STR_LIT>' <EOL> me = self . line_interface . _client . getProfile ( ) <EOL> me . sendMessage ( test_str ) <EOL> result = self . line_interface . polling_command ( ) <EOL> me , msg = result [ <NUM_LIT:0> ] <EOL> self . line_interface . send_message ( me , test_str ) <EOL> result = self . line_interface . polling_command ( ) <EOL> me , msg = result [ <NUM_LIT:0> ] <EOL> ok_ ( msg == test_str , '<STR_LIT>' . format ( msg , test_str ) ) <EOL> def test_send_message_to_id ( self ) : <EOL> test_str = '<STR_LIT>' <EOL> me = self . line_interface . _client . getProfile ( ) <EOL> me . sendMessage ( test_str ) <EOL> result = self . line_interface . polling_command ( ) <EOL> me , msg = result [ <NUM_LIT:0> ] <EOL> self . line_interface . _send_message_to_id ( me . code , test_str ) <EOL> result = self . line_interface . polling_command ( ) <EOL> me , msg = result [ <NUM_LIT:0> ] <EOL> ok_ ( msg == test_str , '<STR_LIT>' . format ( msg , test_str ) ) <EOL> def test_get_display_name ( self ) : <EOL> test_str = '<STR_LIT>' <EOL> me = self . line_interface . _client . getProfile ( ) <EOL> me . sendMessage ( test_str ) <EOL> result = self . line_interface . polling_command ( ) <EOL> me_submitter , msg = result [ <NUM_LIT:0> ] <EOL> me_display_name = self . line_interface . get_display_name ( me_submitter ) <EOL> ok_ ( me_display_name == me . name ) </s>
