def test_chat_closechat_exit(): cshell = CryptoShell('main.cfg') cshell.test_mode = True eq_(cshell.do_chat(''), False) eq_(cshell.do_chat('*****@*****.**'), True) eq_(cshell.do_chat('cryptoim'), True) eq_(cshell.do_chat('shouldntwork'), False) eq_(cshell.do_connect('cryptoim2'), True) TestXMPP.waitForSession(cshell.messenger, True) eq_(cshell.do_send('Test message'), True) eq_(cshell.do_s('Test message for short version'), True) eq_(cshell.do_send(''), False) eq_(cshell.do_closechat(''), True) eq_(cshell.do_closechat(''), False) eq_(cshell.do_send('Test message after stopchat'), False) eq_(cshell.do_s('Alsto testing the short version'), False) cshell.do_disconnect('') exit_code = -1 try: cshell.do_exit('') except SystemExit: exit_code = 0 eq_(0, exit_code)
def test_connect_disconnect(): cshell = CryptoShell('main.cfg') cshell.test_mode = True eq_(cshell.do_connect(''), False) eq_(cshell.do_connect('invalid number of arguments'), False) eq_(cshell.do_connect('cryptoim'), True) eq_(cshell.do_connect('cryptoim'), False) eq_(cshell.do_disconnect('random_string'), True) # branch coverage eq_(cshell.do_disconnect(''), False) exit_code = -1 try: cshell.do_q('') except SystemExit: exit_code = 0 eq_(0, exit_code)
def test_connect_disconnect_jid(): cshell = CryptoShell('main.cfg') cshell.test_mode = True eq_( cshell.do_connect( '[email protected]/random_resource_gets_stripped crypto_test'), True) eq_(cshell.do_disconnect(''), True) eq_(cshell.do_disconnect(''), False)
def test_send(): cshell = CryptoShell('main.cfg') cshell.test_mode = True eq_(cshell.do_send('cryptoim message before connection'), False) eq_(cshell.do_connect('cryptoim2'), True) TestXMPP.waitForSession(cshell.messenger, True) eq_(cshell.do_send(''), False) eq_(cshell.onecmd(''), None) # just empty line command - emptyline() test eq_(cshell.do_send('shouldntwork message'), False) eq_(cshell.do_send('cryptoim message'), True) eq_(cshell.do_send('[email protected] message'), True) eq_(cshell.do_send('cryptoim'), False) cshell.do_disconnect('')