Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/cgit/tests/test_lister.py
# Copyright (C) 2019 the Software Heritage developers | # Copyright (C) 2019 the Software Heritage developers | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from swh.lister import __version__ | |||||
def test_lister_no_page(requests_mock_datadir, swh_listers): | def test_lister_no_page(requests_mock_datadir, swh_listers): | ||||
lister = swh_listers['cgit'] | lister = swh_listers['cgit'] | ||||
assert lister.url == 'https://git.savannah.gnu.org/cgit/' | assert lister.url == 'https://git.savannah.gnu.org/cgit/' | ||||
repos = list(lister.get_repos()) | repos = list(lister.get_repos()) | ||||
assert len(repos) == 977 | assert len(repos) == 977 | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | for row in r: | ||||
url = args[0] | url = args[0] | ||||
assert url.startswith('https://git.tizen') | assert url.startswith('https://git.tizen') | ||||
# kwargs | # kwargs | ||||
kwargs = row['arguments']['kwargs'] | kwargs = row['arguments']['kwargs'] | ||||
assert kwargs == {} | assert kwargs == {} | ||||
assert row['policy'] == 'recurring' | assert row['policy'] == 'recurring' | ||||
assert row['priority'] is None | assert row['priority'] is None | ||||
def test_lister_requests(requests_mock_datadir, swh_listers): | |||||
lister = swh_listers['cgit'] | |||||
lister.url = 'https://git.tizen/cgit/' | |||||
lister.run() | |||||
assert len(requests_mock_datadir.request_history) != 0 | |||||
for request in requests_mock_datadir.request_history: | |||||
assert 'User-Agent' in request.headers | |||||
user_agent = request.headers['User-Agent'] | |||||
assert 'Software Heritage Lister' in user_agent | |||||
assert __version__ in user_agent |