listers: Ensure run can be called without bounds arguments

Closes T2001
This commit is contained in:
Antoine Lambert 2019-09-17 15:09:04 +02:00
parent 4c8d7baf75
commit 7572228f7c
6 changed files with 25 additions and 14 deletions

View file

@ -5,7 +5,7 @@
import logging
import iso8601
from datetime import datetime
from datetime import datetime, timezone
from urllib import parse
from swh.lister.bitbucket.models import BitBucketModel
@ -21,7 +21,7 @@ class BitBucketLister(IndexingHttpLister):
LISTER_NAME = 'bitbucket'
DEFAULT_URL = 'https://api.bitbucket.org/2.0'
instance = 'bitbucket'
default_min_bound = datetime.utcfromtimestamp(0)
default_min_bound = datetime.fromtimestamp(0, timezone.utc)
def __init__(self, url=None, override_config=None, per_page=100):
super().__init__(url=url, override_config=override_config)

View file

@ -35,6 +35,16 @@ class BitBucketListerTester(HttpListerTester, unittest.TestCase):
entries_per_page = 10
convert_type = staticmethod(convert_type)
def request_index(self, request):
"""(Override) This is needed to emulate the listing bootstrap
when no min_bound is provided to run
"""
m = self.test_re.search(request.path_url)
idx = convert_type(m.group(1))
if idx == self.Lister.default_min_bound:
idx = self.first_index
return idx
@requests_mock.Mocker()
def test_fetch_none_nodb(self, http_mocker):
"""Overridden because index is not an integer nor a string