Skip to content

Commit

Permalink
Merge pull request #313 from CDLUC3/fix-312
Browse files Browse the repository at this point in the history
Fix 312
  • Loading branch information
datadavev authored Jun 22, 2022
2 parents 062e240 + 6f3a63e commit bf598bf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
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

0 comments on commit bf598bf

Please sign in to comment.