phabricator/lister: Fix get_next_target_from_response return type
Without that fix, errors are raised when one wants to list Phabricator repositories in a specific index range. The issue is due to a comparison between a string and an integer. So convert next extracted repository index to integer to match the corresponding model type. Closes T1997
This commit is contained in:
parent
1ebe762ea6
commit
e83902c2a3
2 changed files with 13 additions and 3 deletions
|
@ -80,9 +80,8 @@ class PhabricatorLister(IndexingHttpLister):
|
|||
|
||||
def get_next_target_from_response(self, response):
|
||||
body = response.json()['result']['cursor']
|
||||
if body['after'] != 'null':
|
||||
return body['after']
|
||||
return None
|
||||
if body['after'] and body['after'] != 'null':
|
||||
return int(body['after'])
|
||||
|
||||
def transport_response_simplified(self, response):
|
||||
repos = response.json()
|
||||
|
|
|
@ -84,3 +84,14 @@ class PhabricatorListerTester(HttpListerTester, unittest.TestCase):
|
|||
ingested_repos = list(fl.db_query_range(self.first_index,
|
||||
self.last_index))
|
||||
self.assertEqual(len(ingested_repos), self.entries_per_page)
|
||||
|
||||
@requests_mock.Mocker()
|
||||
def test_range_listing(self, http_mocker):
|
||||
fl = self.create_fl_with_db(http_mocker)
|
||||
|
||||
fl.run(max_bound=self.last_index - 1)
|
||||
|
||||
self.assertEqual(fl.db_last_index(), self.last_index - 1)
|
||||
ingested_repos = list(fl.db_query_range(self.first_index,
|
||||
self.last_index))
|
||||
self.assertEqual(len(ingested_repos), self.entries_per_page - 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue