tasks: normalize the url argument name of most lister
Since all the listing tasks accepts an url as first argument (whatever the argument name is), it makes sense to use a simple common argument name for this. I've chosen 'url' instead of api_baseurl/forge_url/url. Also kill now useless `new_lister()` functions.
This commit is contained in:
parent
631b8e7668
commit
b810876ef8
19 changed files with 60 additions and 91 deletions
|
@ -23,9 +23,8 @@ class BitBucketLister(IndexingHttpLister):
|
|||
instance = 'bitbucket'
|
||||
default_min_bound = datetime.utcfromtimestamp(0)
|
||||
|
||||
def __init__(self, api_baseurl=None, override_config=None, per_page=100):
|
||||
super().__init__(
|
||||
api_baseurl=api_baseurl, override_config=override_config)
|
||||
def __init__(self, url=None, override_config=None, per_page=100):
|
||||
super().__init__(url=url, override_config=override_config)
|
||||
per_page = self.config.get('per_page', per_page)
|
||||
|
||||
self.PATH_TEMPLATE = '%s&pagelen=%s' % (
|
||||
|
|
|
@ -12,20 +12,16 @@ from .lister import BitBucketLister
|
|||
GROUP_SPLIT = 10000
|
||||
|
||||
|
||||
def new_lister(api_baseurl='https://api.bitbucket.org/2.0', per_page=100):
|
||||
return BitBucketLister(api_baseurl=api_baseurl, per_page=per_page)
|
||||
|
||||
|
||||
@app.task(name=__name__ + '.IncrementalBitBucketLister')
|
||||
def list_bitbucket_incremental(**lister_args):
|
||||
'''Incremental update of the BitBucket forge'''
|
||||
lister = new_lister(**lister_args)
|
||||
lister = BitBucketLister(**lister_args)
|
||||
lister.run(min_bound=lister.db_last_index(), max_bound=None)
|
||||
|
||||
|
||||
@app.task(name=__name__ + '.RangeBitBucketLister')
|
||||
def _range_bitbucket_lister(start, end, **lister_args):
|
||||
lister = new_lister(**lister_args)
|
||||
lister = BitBucketLister(**lister_args)
|
||||
lister.run(min_bound=start, max_bound=end)
|
||||
|
||||
|
||||
|
@ -36,7 +32,7 @@ def list_bitbucket_full(self, split=None, **lister_args):
|
|||
It's not to be called for an initial listing.
|
||||
|
||||
"""
|
||||
lister = new_lister(**lister_args)
|
||||
lister = BitBucketLister(**lister_args)
|
||||
ranges = lister.db_partition_indices(split or GROUP_SPLIT)
|
||||
if not ranges:
|
||||
self.log.info('Nothing to list')
|
||||
|
|
|
@ -26,8 +26,7 @@ def test_incremental(lister, swh_app, celery_session_worker):
|
|||
res.wait()
|
||||
assert res.successful()
|
||||
|
||||
lister.assert_called_once_with(
|
||||
api_baseurl='https://api.bitbucket.org/2.0', per_page=100)
|
||||
lister.assert_called_once_with()
|
||||
lister.db_last_index.assert_called_once_with()
|
||||
lister.run.assert_called_once_with(min_bound=42, max_bound=None)
|
||||
|
||||
|
@ -45,8 +44,7 @@ def test_range(lister, swh_app, celery_session_worker):
|
|||
res.wait()
|
||||
assert res.successful()
|
||||
|
||||
lister.assert_called_once_with(
|
||||
api_baseurl='https://api.bitbucket.org/2.0', per_page=100)
|
||||
lister.assert_called_once_with()
|
||||
lister.db_last_index.assert_not_called()
|
||||
lister.run.assert_called_once_with(min_bound=12, max_bound=42)
|
||||
|
||||
|
@ -76,8 +74,7 @@ def test_relister(lister, swh_app, celery_session_worker):
|
|||
break
|
||||
sleep(1)
|
||||
|
||||
lister.assert_called_with(
|
||||
api_baseurl='https://api.bitbucket.org/2.0', per_page=100)
|
||||
lister.assert_called_with()
|
||||
|
||||
# one by the FullBitbucketRelister task
|
||||
# + 5 for the RangeBitbucketLister subtasks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue