Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/npm/tests/test_npm_lister.py
# Copyright (C) 2018 the Software Heritage developers | # Copyright (C) 2018 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 | ||||
import re | import re | ||||
import requests_mock | import requests_mock | ||||
import unittest | import unittest | ||||
from swh.lister.core.tests.test_lister import HttpListerTesterBase | from swh.lister.core.tests.test_lister import HttpListerTesterBase | ||||
from swh.lister.npm.lister import NpmLister | from swh.lister.npm.lister import NpmLister, NpmIncrementalLister | ||||
class NpmListerTester(HttpListerTesterBase, unittest.TestCase): | class NpmListerTester(HttpListerTesterBase, unittest.TestCase): | ||||
Lister = NpmLister | Lister = NpmLister | ||||
test_re = re.compile(r'^.*/_all_docs\?startkey=%22(.+)%22.*') | test_re = re.compile(r'^.*/_all_docs\?startkey=%22(.+)%22.*') | ||||
lister_subdir = 'npm' | lister_subdir = 'npm' | ||||
good_api_response_file = 'api_response.json' | good_api_response_file = 'api_response.json' | ||||
bad_api_response_file = 'api_empty_response.json' | bad_api_response_file = 'api_empty_response.json' | ||||
first_index = 'jquery' | first_index = 'jquery' | ||||
entries_per_page = 100 | entries_per_page = 100 | ||||
@requests_mock.Mocker() | @requests_mock.Mocker() | ||||
def test_is_within_bounds(self, http_mocker): | def test_is_within_bounds(self, http_mocker): | ||||
# disable this test from HttpListerTesterBase as | # disable this test from HttpListerTesterBase as | ||||
# it can not succeed for the npm lister due to the | # it can not succeed for the npm lister due to the | ||||
# overriding of the string_pattern_check method | # overriding of the string_pattern_check method | ||||
pass | pass | ||||
class NpmIncrementalListerTester(HttpListerTesterBase, unittest.TestCase): | |||||
Lister = NpmIncrementalLister | |||||
test_re = re.compile(r'^.*/_changes\?since=([0-9]+).*') | |||||
lister_subdir = 'npm' | |||||
good_api_response_file = 'api_inc_response.json' | |||||
bad_api_response_file = 'api_inc_empty_response.json' | |||||
first_index = 6920642 | |||||
entries_per_page = 100 | |||||
@requests_mock.Mocker() | |||||
def test_is_within_bounds(self, http_mocker): | |||||
# disable this test from HttpListerTesterBase as | |||||
# it can not succeed for the npm lister due to the | |||||
# overriding of the string_pattern_check method | |||||
pass |