Пример #1
0
def test_return_cli():

    cshell = CryptoShell('tests/test_config.cfg')
    cshell.test_mode = True
    eq_(cshell.return_cli(False), False)
    eq_(cshell.return_cli(True), True)
    eq_(cshell.return_cli('test'), 'test')
    eq_(cshell.return_cli(123), 123)
    cshell.test_mode = False
    eq_(cshell.return_cli(False), None)
    eq_(cshell.return_cli(True), None)
    eq_(cshell.return_cli('test'), None)
    eq_(cshell.return_cli(123), None)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
def test_addfriend_removefriend():

    cshell = CryptoShell('tests/test_config.cfg')
    cshell.test_mode = True

    eq_(cshell.do_addfriend('testfriend [email protected]'), True)
    eq_(cshell.do_addfriend('testfriend [email protected]'), False)
    eq_(cshell.do_addfriend(''), False)
    eq_(cshell.do_removefriend('testfriend'), True)
    eq_(cshell.do_removefriend('testfriend another few lines'), False)
    eq_(cshell.do_removefriend(''), False)
    eq_(cshell.do_removefriend('testfriend'), False)
Пример #5
0
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('')
Пример #6
0
def test_addconnection_removeconnection():

    cshell = CryptoShell('tests/test_config.cfg')
    cshell.test_mode = True

    eq_(cshell.do_addconnection('testuser2 [email protected] testpass'),
        True)
    eq_(cshell.do_addconnection('testuser2 [email protected] testpass'),
        False)
    eq_(cshell.do_addconnection('testuser2'), False)
    eq_(cshell.do_addconnection('testuser3'), False)
    eq_(cshell.do_addconnection('testuser3 thisisnotajid testpass'), False)
    eq_(cshell.do_removeconnection('testuser3'), False)
    eq_(cshell.do_removeconnection('testuser2 [email protected]'), False)
    eq_(cshell.do_removeconnection('*****@*****.**'), False)
    eq_(cshell.do_removeconnection('testuser2'), True)
Пример #7
0
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)
Пример #8
0
def test_friendlist():

    cshell = CryptoShell('main.cfg')
    cshell.test_mode = True
    eq_(cshell.do_friendlist(''), None)
    eq_(cshell.do_friendlist('whatever string'), None)