Skip to content
Snippets Groups Projects
Verified Commit d640fdcc authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

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

parent b9544c77
No related branches found
No related tags found
No related merge requests found
......@@ -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'
......
......@@ -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)
......
......@@ -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'
......
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment