Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 312 #313

Merged
merged 3 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ezidapp/models/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def publicationDate(date):
# return ("%04d", "%04d-%02d", "%04d-%02d-%02d")[numComponents - 1] % t[:numComponents]
return ("{:04d}", "{:04d}-{:02d}", "{:04d}-{:02d}-{:02d}")[
numComponents - 1
].format(t[:numComponents])
].format(*t[:numComponents])
except Exception:
pass
raise django.core.exceptions.ValidationError(
Expand Down
7 changes: 7 additions & 0 deletions tests/test_docs/datacite_metadata_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# For input to client testing datacite minting
# client.py l admin mint doi:10.5072/FK2 @datacite_metadata_01.txt
datacite.creator: Dave
datacite.title: Test doc
datacite.publicationyear: 1961
datacite.resourcetype: Event
datacite.publisher: Tester
20 changes: 20 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright©2021, Regents of the University of California
# http://creativecommons.org/licenses/BSD

"""Test ezidapp.models.validation
"""

import pytest

import ezidapp.models.validation

#TODO: Flesh out the test cases to match all the possibilities in the tested method
@pytest.mark.parametrize("test,expected",[
('1961', '1961'),
('196104','1961-04'),
('20201201', '2020-12-01'),
])
def test_publicationDate(test, expected):
res = ezidapp.models.validation.publicationDate(test)
assert res == expected