Skip to content

Commit

Permalink
Fixed exit test
Browse files Browse the repository at this point in the history
  • Loading branch information
oskopek committed Jan 22, 2014
1 parent 672e479 commit e6ccabb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
25 changes: 12 additions & 13 deletions cryptoim/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def do_exit(self, arg):

self.do_disconnect(arg)
self.print_cmd('Thank you for using CryptoIM!')
quit()
sys.exit(0)

def do_q(self, arg):
'Alias for quit'
Expand Down Expand Up @@ -141,7 +141,7 @@ def do_addconnection(self, arg):
if not sanit_is_jid(splitted[1]):
self.print_cmd('JID has form of username@host.')
self.print_cmd('Usage: addconnection <username> <JID> <password>')
return self.return_cli(False)
return self.return_cli(False)

self.config.add_section(splitted[0])
self.config.set(splitted[0], 'username', splitted[0])
Expand Down Expand Up @@ -170,7 +170,7 @@ def do_removeconnection(self, arg):

with open(self.config_file, 'w') as conf:
self.config.write(conf)
return self.return_cli(True)
return self.return_cli(True)

def do_s(self, arg):
'send toJID or username msg'
Expand Down Expand Up @@ -222,25 +222,25 @@ def do_addfriend(self, arg):

if self.config_find(splitted[0]):
self.print_cmd('Already in your friend list.')
return
return

self.config.set('friends', splitted[0], splitted[1])
with open(self.config_file, 'w') as conf:
self.config.write(conf)
return
return

def do_removefriend(self, arg):
'removefriend name'
splitted = arg.split(' ')

if self.config_find(splitted[0]):
self.print_cmd('Not in your friend list.')
return
return

self.config.remove_option('friends', splitted[0])
with open(self.config_file, 'w') as conf:
self.config.write(conf)
return
return

def do_chat(self, arg):
"""
Expand Down Expand Up @@ -321,10 +321,14 @@ def config_find(self, param, section='friends'):
return None

def return_cli(self, value):
"""
If in test mode, return value from param
"""

if self.test_mode:
return value
else:
return
return

# End of class

Expand Down Expand Up @@ -362,8 +366,3 @@ def address_format(jid, msg):
Formats a jid and message to correctly display in the log
"""
return(jid + ': ' + msg)

def test_cli(parameter):
if parameter == 'true':
return True
return False
11 changes: 8 additions & 3 deletions tests/TestCli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def test_chat_stopchat_exit():
eq_(cshell.do_send('Test message after stopchat'), False)
eq_(cshell.do_s('Alsto testing the short version'), False)
cshell.do_disconnect('')
#cshell.do_exit('')



exit_code = -1
try:
cshell.do_exit('')
except SystemExit:
exit_code = 0
eq_(0, exit_code)

0 comments on commit e6ccabb

Please sign in to comment.