Skip to content

Commit

Permalink
*Fixing PEP8 and increasing the version getting ready to release
Browse files Browse the repository at this point in the history
*Fixing test fixture to run same version of python for responder
*Fixing tabs to spaces for uniformity.
  • Loading branch information
attzonko committed Aug 29, 2018
1 parent 2eb5dc0 commit fdb1651
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mmpy_bot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (1, 2, 1)
VERSION = (1, 3, 0)


def get_version():
Expand Down
6 changes: 4 additions & 2 deletions mmpy_bot/mattermost.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def login(self, team, account, password):
response = self._login(props)
if response.status_code in [301, 302, 307]:
# reset self.url to the new URL
self.url = response.headers['Location'].replace('/users/login', '')
self.url = response.headers['Location'].replace(
'/users/login', '')
# re-try login if redirected
response = self._login(props)
if response.status_code == 200:
Expand All @@ -143,7 +144,8 @@ def _login(self, props):
def load_initial_data(self):
self.teams = self.get('/users/me/teams')
if len(self.teams) == 0:
raise AssertionError('User account of this bot does not join any team yet.')
raise AssertionError(
'User account of this bot does not join any team yet.')
self.default_team_id = self.teams[0]['id']
self.teams_channels_ids = {}
for team in self.teams:
Expand Down
1 change: 1 addition & 0 deletions mmpy_bot/plugins/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from mmpy_bot.bot import respond_to, listen_to


@respond_to('^\!info$')
@listen_to('^\!info$')
def info_request(message):
Expand Down
4 changes: 2 additions & 2 deletions mmpy_bot/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def set_next_run(self, next_time):
self.next_run = next_time

def run(self):
try: # py3+
try: # py3+
ret = super().run()
except TypeError: # py2.7
except TypeError: # py2.7
ret = super(OneTimeJob, self).run()
self.scheduler.cancel_job(self)
return ret
Expand Down
10 changes: 5 additions & 5 deletions tests/behavior_tests/bots/test_plugins/test_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

@respond_to('reply \"(.*)\" at (.*)', re.IGNORECASE)
def reply_specific_time(message, content, trigger_time):
t_time = datetime.strptime(trigger_time, '%b-%d-%Y_%H:%M:%S')
schedule.once(t_time).do(message.reply, content)
t_time = datetime.strptime(trigger_time, '%b-%d-%Y_%H:%M:%S')
schedule.once(t_time).do(message.reply, content)


@respond_to('reply \"(.*)\" every (.*) seconds', re.IGNORECASE)
def reply_every_seconds(message, content, seconds):
schedule.every(int(seconds)).seconds.do(message.reply, content)
schedule.every(int(seconds)).seconds.do(message.reply, content)


@respond_to('cancel jobs', re.IGNORECASE)
def cancel_jobs(message):
schedule.clear()
message.reply('all jobs canceled.')
schedule.clear()
message.reply('all jobs canceled.')
6 changes: 4 additions & 2 deletions tests/behavior_tests/fixture.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import sys
import subprocess
import pytest
from tests.behavior_tests.bots.driver import Driver


def _start_bot_process():
"""
Function to run a bot for testing in subprocess
Function to run a bot for testing in a subprocess
"""
args = ['python', 'tests/behavior_tests/bots/responder.py', ]
args = [sys.executable, 'tests/behavior_tests/bots/responder.py',]
return subprocess.Popen(args)


Expand All @@ -16,6 +17,7 @@ def driver():
driver = Driver()
driver.start()
p = _start_bot_process()
print(p)
driver.wait_for_bot_online()
yield driver
p.terminate()

0 comments on commit fdb1651

Please sign in to comment.