|
19 | 19 | from packages_test_utils import PackageTester |
20 | 20 | from scancode_config import REGEN_TEST_FIXTURES |
21 | 21 |
|
22 | | -REGEN_TEST_FIXTURES = False |
23 | | - |
24 | 22 | # TODO: Add test with https://rubygems.org/gems/pbox2d/versions/1.0.3-java |
25 | 23 | # this is a multiple personality package (Java and Ruby) |
26 | 24 | # see also https://rubygems.org/downloads/jaro_winkler-1.5.1-java.gem |
|
29 | 27 | class TestGemspecVersionConstant(PackageTester): |
30 | 28 | test_data_dir = os.path.join(os.path.dirname(__file__), 'data') |
31 | 29 |
|
32 | | - def test_version_constant_returns_none_for_elasticsearch(self): |
33 | | - test_file = self.get_test_loc('rubygems/version-constant/elasticsearch-api.gemspec') |
| 30 | + def _check_version_constant_package(self, test_path, expected_name): |
| 31 | + test_file = self.get_test_loc(test_path) |
34 | 32 | packages = list(rubygems.GemspecHandler.parse(test_file)) |
35 | 33 | assert packages |
36 | 34 | pkg = packages[0] |
37 | | - assert pkg.name == 'elasticsearch-api' |
| 35 | + assert pkg.name == expected_name |
38 | 36 | assert pkg.version is None |
39 | | - assert 'Elasticsearch' not in str(pkg.version) |
40 | 37 | assert pkg.download_url is None |
| 38 | + assert pkg.api_data_url == f'https://rubygems.org/api/v1/versions/{expected_name}.json' |
| 39 | + return pkg |
| 40 | + |
| 41 | + def test_version_constant_returns_none_for_elasticsearch(self): |
| 42 | + pkg = self._check_version_constant_package( |
| 43 | + test_path='rubygems/version-constant/elasticsearch-api.gemspec', |
| 44 | + expected_name='elasticsearch-api', |
| 45 | + ) |
| 46 | + assert 'Elasticsearch' not in str(pkg.version) |
| 47 | + |
| 48 | + def test_version_constant_returns_none_for_excon(self): |
| 49 | + self._check_version_constant_package( |
| 50 | + test_path='rubygems/version-constant/excon.gemspec', |
| 51 | + expected_name='excon', |
| 52 | + ) |
| 53 | + |
| 54 | + def test_version_constant_returns_none_for_faraday(self): |
| 55 | + self._check_version_constant_package( |
| 56 | + test_path='rubygems/version-constant/faraday.gemspec', |
| 57 | + expected_name='faraday', |
| 58 | + ) |
41 | 59 |
|
42 | 60 | def test_version_constant_returns_none_for_simple_constant(self): |
43 | | - test_file = self.get_test_loc('rubygems/version-constant/simple-constant.gemspec') |
44 | | - packages = list(rubygems.GemspecHandler.parse(test_file)) |
45 | | - assert packages |
46 | | - pkg = packages[0] |
47 | | - assert pkg.name == 'my-gem' |
48 | | - assert pkg.version is None |
| 61 | + self._check_version_constant_package( |
| 62 | + test_path='rubygems/version-constant/simple-constant.gemspec', |
| 63 | + expected_name='my-gem', |
| 64 | + ) |
49 | 65 |
|
50 | 66 | def test_real_version_is_preserved(self): |
51 | 67 | test_file = self.get_test_loc('rubygems/version-constant/simple-version.gemspec') |
|
0 commit comments