tests: Separate lister instantiations

Prior to this commit, all listers were instantiated at the same time even if
only one was needed. This commit separates those instantiations.

The only drawback to this is the db model initialization which now happens at
each lister instantiation. This can be dealt with if needed at another time
though.
This commit is contained in:
Antoine R. Dumont (@ardumont) 2020-09-02 09:47:12 +02:00
parent 92422dcf75
commit 5a5b7ef70b
No known key found for this signature in database
GPG key ID: 52E2E9840D10C3B8
14 changed files with 127 additions and 87 deletions

View file

@ -6,6 +6,7 @@
import re
import unittest
import pytest
import requests_mock
from swh.lister.core.tests.test_lister import HttpListerTester
@ -57,15 +58,18 @@ class GitHubListerTester(HttpListerTester, unittest.TestCase):
)
def test_lister_github(swh_listers, requests_mock_datadir):
@pytest.fixture
def lister_under_test():
return "github"
def test_lister_github(swh_lister, requests_mock_datadir):
"""Simple github listing should create scheduled tasks
"""
lister = swh_listers["github"]
swh_lister.run()
lister.run()
r = lister.scheduler.search_tasks(task_type="load-git")
r = swh_lister.scheduler.search_tasks(task_type="load-git")
assert len(r) == 100
for row in r: