# Only weed out MRs less than the soak time for the crontab output (where author==None)
now = datetime.now(timezone.utc)
- creation_time = parser.parse(mr_attrs['created_at'], tzinfos=tzutc)
+ creation_time = parser.parse(mr_attrs['created_at'], tzinfos=[tzutc()]).astimezone(timezone.utc)
if not author:
self.log.info("times: {}, {}, {}".format(creation_time, self.soak_delta, now))
if creation_time + self.soak_delta > now:
msg = "Couldn't find {} hooks".format(repo)
self.log.error("watchrepo: {}".format(msg))
return msg
- else:
- for a_hook in hooks:
- self.log.info('a_hook: {}'.format(a_hook))
- hook_attributes = a_hook.attributes
- if hook_attributes['merge_requests_events'] and hook_attributes['url'].startswith(self.webhook_url):
- marge_hook = a_hook
- break
+
+ for a_hook in hooks:
+ self.log.info('a_hook: {}'.format(a_hook))
+ hook_attributes = a_hook.attributes
+ if hook_attributes['merge_requests_events'] and hook_attributes['url'].startswith(self.webhook_url):
+ marge_hook = a_hook
+ break
# If so replace it (or error out ?)
url = "{}{}".format(self.webhook_url, rooms) # webhooks_url will end in '/'
hook_updated = True
if marge_hook:
-
old_rooms = marge_hook.attributes['url'].split(self.webhook_url, 1)[1]
if old_rooms == rooms:
msg = "Already reporting {} MRs to the {} room(s)".format(repo, rooms)
self.log.info('watchrepo: {}'.format(msg))
return msg
- else:
- try:
- s_action = "update"
- marge_hook.attributes['url'] = url
- marge_hook.save()
- s_watch_msg = "Updating room list for {} MRs from {} to {}".format(repo, old_rooms, rooms)
- except Exception as exp:
- hook_updated = False
- self.log.error("watchrepo; update hook {} raised exception {}".format(repo, exp))
+ try:
+ s_action = "update"
+ marge_hook.attributes['url'] = url
+ marge_hook.save()
+ s_watch_msg = "Updating room list for {} MRs from {} to {}".format(repo, old_rooms, rooms)
+ except Exception as exp:
+ hook_updated = False
+ self.log.error("watchrepo; update hook {} raised exception {}".format(repo, exp))
else:
try:
s_action = "add"
from queue import Empty
from dateutil.relativedelta import relativedelta
-import pytest
import requests
-import errbot
from errbot.backends.test import testbot # pylint: disable=unused-import
+import errbot
+import pytest
from httmock import urlmatch, HTTMock
from plugins.marge import deltastr
'url': 'https://webhook.errbot.com:3142/margebot/room1,room2,room3'}])}
-class TestMarge(object):
+class TestMarge:
"""
Margebot Tests