Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_metadata.py
Show First 20 Lines • Show All 541 Lines • ▼ Show 20 Lines | def test_compute_metadata_maven(self): | ||||
'name': 'Maven Default Project', | 'name': 'Maven Default Project', | ||||
'identifier': 'com.mycompany.app', | 'identifier': 'com.mycompany.app', | ||||
'version': '1.2.3', | 'version': '1.2.3', | ||||
'license': 'https://www.apache.org/licenses/LICENSE-2.0.txt', | 'license': 'https://www.apache.org/licenses/LICENSE-2.0.txt', | ||||
'codeRepository': | 'codeRepository': | ||||
'http://repo1.maven.org/maven2/com/mycompany/app/my-app', | 'http://repo1.maven.org/maven2/com/mycompany/app/my-app', | ||||
}) | }) | ||||
def test_compute_metadata_maven_almost_empty(self): | |||||
raw_content = b""" | |||||
<project> | |||||
<foo/> | |||||
</project>""" | |||||
result = MAPPINGS["MavenMapping"].translate(raw_content) | |||||
self.assertEqual(result, { | |||||
'@context': 'https://doi.org/10.5063/schema/codemeta-2.0', | |||||
'type': 'SoftwareSourceCode', | |||||
}) | |||||
def test_compute_metadata_maven_minimal(self): | def test_compute_metadata_maven_minimal(self): | ||||
raw_content = b""" | raw_content = b""" | ||||
<project> | <project> | ||||
<name>Maven Default Project</name> | <name>Maven Default Project</name> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
<groupId>com.mycompany.app</groupId> | <groupId>com.mycompany.app</groupId> | ||||
<artifactId>my-app</artifactId> | <artifactId>my-app</artifactId> | ||||
<version>1.2.3</version> | <version>1.2.3</version> | ||||
</project>""" | </project>""" | ||||
result = MAPPINGS["MavenMapping"].translate(raw_content) | result = MAPPINGS["MavenMapping"].translate(raw_content) | ||||
self.assertEqual(result, { | self.assertEqual(result, { | ||||
'@context': 'https://doi.org/10.5063/schema/codemeta-2.0', | '@context': 'https://doi.org/10.5063/schema/codemeta-2.0', | ||||
'type': 'SoftwareSourceCode', | 'type': 'SoftwareSourceCode', | ||||
'name': 'Maven Default Project', | 'name': 'Maven Default Project', | ||||
'identifier': 'com.mycompany.app', | 'identifier': 'com.mycompany.app', | ||||
'version': '1.2.3', | 'version': '1.2.3', | ||||
'codeRepository': | 'codeRepository': | ||||
'https://repo.maven.apache.org/maven2/com/mycompany/app/my-app', | 'https://repo.maven.apache.org/maven2/com/mycompany/app/my-app', | ||||
'license': [], | |||||
}) | }) | ||||
def test_compute_metadata_maven_multiple(self): | def test_compute_metadata_maven_multiple(self): | ||||
'''Tests when there are multiple code repos and licenses.''' | '''Tests when there are multiple code repos and licenses.''' | ||||
raw_content = b""" | raw_content = b""" | ||||
<project> | <project> | ||||
<name>Maven Default Project</name> | <name>Maven Default Project</name> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |