Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_metadata.py
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | def setUp(self): | ||||
""" | """ | ||||
self.maxDiff = None | self.maxDiff = None | ||||
self.npm_mapping = MAPPINGS["NpmMapping"]() | self.npm_mapping = MAPPINGS["NpmMapping"]() | ||||
self.codemeta_mapping = MAPPINGS["CodemetaMapping"]() | self.codemeta_mapping = MAPPINGS["CodemetaMapping"]() | ||||
self.maven_mapping = MAPPINGS["MavenMapping"]() | self.maven_mapping = MAPPINGS["MavenMapping"]() | ||||
self.pkginfo_mapping = MAPPINGS["PythonPkginfoMapping"]() | self.pkginfo_mapping = MAPPINGS["PythonPkginfoMapping"]() | ||||
self.gemspec_mapping = MAPPINGS["GemspecMapping"]() | self.gemspec_mapping = MAPPINGS["GemspecMapping"]() | ||||
self.cff_mapping = MAPPINGS["CffMapping"]() | self.cff_mapping = MAPPINGS["CffMapping"]() | ||||
self.description_mapping = MAPPINGS["RDescriptionMapping"]() | |||||
def test_compute_metadata_none(self): | def test_compute_metadata_none(self): | ||||
""" | """ | ||||
testing content empty content is empty | testing content empty content is empty | ||||
should return None | should return None | ||||
""" | """ | ||||
# given | # given | ||||
content = b"" | content = b"" | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | RIS, schema.org, CodeMeta, and .zenodo.json.""", | ||||
"version": "1.4.0-alpha0", | "version": "1.4.0-alpha0", | ||||
} | } | ||||
# when | # when | ||||
result = self.cff_mapping.translate(content) | result = self.cff_mapping.translate(content) | ||||
# then | # then | ||||
self.assertEqual(expected, result) | self.assertEqual(expected, result) | ||||
def test_compute_metadata_description(self): | |||||
""" | |||||
testing DESCRIPTION translation | |||||
""" | |||||
# given | |||||
content = """Package: desc | |||||
Title: Manipulate DESCRIPTION Files | |||||
Version: 1.3.0.9000 | |||||
Authors@R: | |||||
c(person(given = "Gábor", | |||||
family = "Csárdi", | |||||
role = c("aut", "cre"), | |||||
email = "csardi.gabor@gmail.com"), | |||||
person(given = "Kirill", | |||||
family = "Müller", | |||||
role = "aut"), | |||||
person(given = "Jim", | |||||
family = "Hester", | |||||
role = "aut", | |||||
email = "james.f.hester@gmail.com"), | |||||
person(given = "Maëlle", | |||||
family = "Salmon", | |||||
role = "ctb", | |||||
comment = c(ORCID = "0000-0002-2815-0399"))) | |||||
Maintainer: Gábor Csárdi <csardi.gabor@gmail.com> | |||||
Description: Tools to read, write, create, and manipulate DESCRIPTION files. | |||||
It is intended for packages that create or manipulate other packages. | |||||
License: MIT + file LICENSE | |||||
LazyData: true | |||||
URL: https://github.com/r-lib/desc#readme | |||||
BugReports: https://github.com/r-lib/desc/issues | |||||
Depends: | |||||
R (>= 3.1.0) | |||||
Suggests: | |||||
covr, | |||||
testthat, | |||||
whoami, | |||||
withr, | |||||
spelling, | |||||
gh | |||||
Imports: | |||||
utils, | |||||
R6, | |||||
crayon, | |||||
rprojroot | |||||
Encoding: UTF-8 | |||||
RoxygenNote: 7.1.1.9000 | |||||
Roxygen: list(r6 = FALSE, load = "installed") | |||||
Collate: | |||||
'assertions.R' | |||||
'authors-at-r.R' | |||||
'built.R' | |||||
'classes.R' | |||||
'collate.R' | |||||
'constants.R' | |||||
'deps.R' | |||||
'description.R' | |||||
'encoding.R' | |||||
'latex.R' | |||||
'non-oo-api.R' | |||||
'package-archives.R' | |||||
'read.R' | |||||
'remotes.R' | |||||
'str.R' | |||||
'syntax_checks.R' | |||||
'urls.R' | |||||
'utils.R' | |||||
'validate.R' | |||||
'version.R' | |||||
Language: en-US""".encode( | |||||
"utf-8" | |||||
) | |||||
expected = { | |||||
"@context": "https://doi.org/10.5063/schema/codemeta-2.0", | |||||
"type": "SoftwareSourceCode", | |||||
"description": """Tools to read, write, create, and manipulate DESCRIPTION files.\n \ | |||||
It is intended for packages that create or manipulate other packages.""", | |||||
"schema:identifier": "desc", | |||||
"schema:license": "MIT + file LICENSE", | |||||
"name": "Manipulate DESCRIPTION Files", | |||||
vlorentz: Hmm, this should be automatically converted from `"schema:url"` to `"url"`. I'll look into the… | |||||
"schema:url": "https://github.com/r-lib/desc#readme", | |||||
"codemeta:issueTracker": "https://github.com/r-lib/desc/issues", | |||||
"maintainer": "G\u00e1bor Cs\u00e1rdi <csardi.gabor@gmail.com>", | |||||
} | |||||
# when | |||||
result = self.description_mapping.translate(content) | |||||
# then | |||||
self.assertEqual(expected, result) | |||||
def test_compute_metadata_npm(self): | def test_compute_metadata_npm(self): | ||||
""" | """ | ||||
testing only computation of metadata with hard_mapping_npm | testing only computation of metadata with hard_mapping_npm | ||||
""" | """ | ||||
# given | # given | ||||
content = b""" | content = b""" | ||||
{ | { | ||||
"name": "test_metadata", | "name": "test_metadata", | ||||
▲ Show 20 Lines • Show All 1,146 Lines • Show Last 20 Lines |
Hmm, this should be automatically converted from "schema:url" to "url". I'll look into the issue.