Skip to content

Commit 623eb5a

Browse files
committed
add test for only name version of rust author
1 parent 2c19947 commit 623eb5a

2 files changed

Lines changed: 81 additions & 1 deletion

File tree

tests/data/Cargo.toml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,62 @@ documentation = "https://example.com/test-package"
1010
keywords = ["test", "demo", "example"]
1111
edition = "2021"
1212

13+
[package.metadata.somesy.project]
14+
name = "testproject"
15+
version = "1.0.0"
16+
description = "This is a test project for demonstration purposes."
17+
keywords = ["test", "demo", "example"]
18+
license = "MIT"
19+
repository = "https://github.com/example/testproject"
20+
homepage = "https://example.com/testproject"
21+
22+
[[package.metadata.somesy.project.people]]
23+
family-names = "Doe"
24+
given-names = "John"
25+
email = "john.doe@example.com"
26+
orcid = "https://orcid.org/0000-0000-0000-0000"
27+
28+
contribution = "The main developer, maintainer, and tester."
29+
contribution_begin = "2023-01-15"
30+
contribution_types = ["maintenance", "code", "test", "review", "doc"]
31+
32+
author = true
33+
maintainer = true
34+
publication_author = true
35+
36+
[[package.metadata.somesy.project.people]]
37+
family-names = "Doe"
38+
given-names = "Jane"
39+
email = "jane.doe@example.com"
40+
orcid = "https://orcid.org/0000-0000-0000-0001"
41+
42+
contribution = "Initial concepts, tool development and enhancement, documentation."
43+
contribution_begin = "2023-02-20"
44+
contribution_types = ["ideas", "code", "test", "review", "doc"]
45+
46+
author = true
47+
48+
[[package.metadata.somesy.project.people]]
49+
family-names = "Doe"
50+
given-names = "Michael"
51+
email = "michael.doe@example.com"
52+
orcid = "https://orcid.org/0000-0000-0000-0002"
53+
54+
contribution = "Valuable input concerning metadata standards and usability."
55+
contribution_begin = "2023-03-10"
56+
contribution_types = ["ideas"]
57+
publication_author = true
58+
59+
[package.metadata.somesy.config]
60+
no_sync_cff = false
61+
cff_file = "CITATION.cff"
62+
no_sync_pyproject = false
63+
pyproject_file = "pyproject.toml"
64+
no_sync_codemeta = false
65+
codemeta_file = "codemeta.json"
66+
no_sync_package_json = true
67+
show_info = false
68+
verbose = false
69+
debug = false
70+
1371
[dependencies]

tests/output/test_rust_writer.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ def test_from_to_person(person):
4646
assert p.full_name == person.full_name
4747
assert p.email == person.email
4848

49+
# rust also has only name format
50+
assert Rust._to_person(person.full_name) == None
4951

50-
def test_person_merge_pyproject(rust_file, person):
52+
53+
def test_person_merge(rust_file, person):
5154
pj = Rust(rust_file)
5255
# update project file with known data
5356
pm = ProjectMetadata(
@@ -118,3 +121,22 @@ def test_person_merge_pyproject(rust_file, person):
118121
assert len(pj.maintainers) == 1
119122
assert pj.authors[0] == person1c_rep
120123
assert pj.authors[1] == person3_rep
124+
125+
126+
def test_person_merge_no_email(rust_file, person):
127+
# try with a rust file that has an author with only name
128+
r = Rust(rust_file)
129+
r._data["package"]["authors"] = ["Jane Doe"]
130+
r.save()
131+
132+
# update project file with known data
133+
pm = ProjectMetadata(
134+
name="My-awesome-project",
135+
description="Project description",
136+
license=LicenseEnum.MIT,
137+
version="0.1.0",
138+
people=[person.model_copy(update=dict(author=True, publication_author=True))],
139+
)
140+
141+
r.sync(pm)
142+
assert r.authors[0] == Rust._from_person(person)

0 commit comments

Comments
 (0)