swh.lister.gitlab.tests: Separate properly tests per lister

This commit is contained in:
Antoine R. Dumont (@ardumont) 2018-07-12 11:29:11 +02:00
parent b9544c77f4
commit d640fdcc96
No known key found for this signature in database
GPG key ID: 52E2E9840D10C3B8
4 changed files with 11 additions and 11 deletions

View file

@ -6,10 +6,10 @@ import re
import unittest
from swh.lister.bitbucket.lister import BitBucketLister
from swh.lister.core.tests.test_lister import HttpListerTesterBase
from swh.lister.core.tests.test_lister import HttpListerTester
class BitBucketListerTester(HttpListerTesterBase, unittest.TestCase):
class BitBucketListerTester(HttpListerTester, unittest.TestCase):
Lister = BitBucketLister
test_re = re.compile(r'/repositories\?after=([^?&]+)')
lister_subdir = 'bitbucket'

View file

@ -37,7 +37,6 @@ class HttpListerTesterBase(abc.ABC):
good_api_response_file = AbstractAttribute('Example good response body')
bad_api_response_file = AbstractAttribute('Example bad response body')
first_index = AbstractAttribute('First index in good_api_response')
last_index = AbstractAttribute('Last index in good_api_response')
entries_per_page = AbstractAttribute('Number of results in good response')
LISTER_NAME = 'fake-lister'
@ -215,6 +214,11 @@ class HttpListerTesterBase(abc.ABC):
engine = create_engine(db.url())
model.metadata.create_all(engine)
class HttpListerTester(HttpListerTesterBase, abc.ABC):
last_index = AbstractAttribute('Last index in good_api_response')
@requests_mock.Mocker()
@istest
def test_fetch_multiple_pages_yesdb(self, http_mocker):
http_mocker.get(self.test_re, text=self.mock_response)
@ -227,10 +231,6 @@ class HttpListerTesterBase(abc.ABC):
self.disable_storage_and_scheduler(fl)
# FIXME: Separate the tests properly for the gitlab lister
# did not succeed yet
if not hasattr(fl, 'db_last_index'): # gitlab lister cannot pass here
return
fl.run(min_bound=self.first_index)
self.assertEqual(fl.db_last_index(), self.last_index)

View file

@ -6,11 +6,11 @@ import re
import unittest
from datetime import datetime, timedelta
from swh.lister.core.tests.test_lister import HttpListerTesterBase
from swh.lister.core.tests.test_lister import HttpListerTester
from swh.lister.github.lister import GitHubLister
class GitHubListerTester(HttpListerTesterBase, unittest.TestCase):
class GitHubListerTester(HttpListerTester, unittest.TestCase):
Lister = GitHubLister
test_re = re.compile(r'/repositories\?since=([^?&]+)')
lister_subdir = 'github'

View file

@ -2,6 +2,7 @@
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import re
import unittest
from datetime import datetime, timedelta
@ -12,12 +13,11 @@ from swh.lister.core.tests.test_lister import HttpListerTesterBase
class GitLabListerTester(HttpListerTesterBase, unittest.TestCase):
Lister = GitLabLister
test_re = GitLabLister.API_URL_INDEX_RE
test_re = re.compile(r'^.*/projects.*page=(\d+).*')
lister_subdir = 'gitlab'
good_api_response_file = 'api_response.json'
bad_api_response_file = 'api_empty_response.json'
first_index = 1
last_index = 2
entries_per_page = 10
def response_headers(self, request):