summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/tests/api_releases.py8
-rw-r--r--rust/src/identifiers.rs40
2 files changed, 45 insertions, 3 deletions
diff --git a/python/tests/api_releases.py b/python/tests/api_releases.py
index c0c4ef90..f2a370c3 100644
--- a/python/tests/api_releases.py
+++ b/python/tests/api_releases.py
@@ -199,9 +199,15 @@ def test_controlled_vocab(api):
r1.release_type = "article"
api.create_release(eg.editgroup_id, r1)
- r2 = ReleaseEntity(title="something elase", release_stage="pre-print", ext_ids=ReleaseExtIds())
+ r2 = ReleaseEntity(title="something else", release_stage="pre-print", ext_ids=ReleaseExtIds())
with pytest.raises(fatcat_client.rest.ApiException):
api.create_release(eg.editgroup_id, r2)
r2.release_stage = "published"
api.create_release(eg.editgroup_id, r2)
+ r3 = ReleaseEntity(title="something else", withdrawn_status="boondogle", ext_ids=ReleaseExtIds())
+ with pytest.raises(fatcat_client.rest.ApiException):
+ api.create_release(eg.editgroup_id, r3)
+ r3.withdrawn_status = "spam"
+ api.create_release(eg.editgroup_id, r3)
+
diff --git a/rust/src/identifiers.rs b/rust/src/identifiers.rs
index 37305677..11fae56b 100644
--- a/rust/src/identifiers.rs
+++ b/rust/src/identifiers.rs
@@ -595,6 +595,44 @@ fn test_check_release_stage() {
assert!(check_release_stage("draft ").is_err());
}
+pub fn check_withdrawn_status(raw: &str) -> Result<()> {
+ let valid_types = vec![
+ // Didn't have a controlled vocab so made one up
+ "withdrawn", // generic
+ "retracted",
+ "concern",
+ "legal",
+ "safety",
+ "national-security",
+ "spam",
+
+ // potential more-specific statuses
+ //"author-misconduct",
+ //"author-mistake",
+ //"publisher-misconduct",
+ //"publisher-mistake",
+ //"unreliable",
+ ];
+ for good in valid_types {
+ if raw == good {
+ return Ok(());
+ }
+ }
+ Err(FatcatError::NotInControlledVocabulary(
+ "withdrawn_status (controlled vocabulary)".to_string(),
+ raw.to_string(),
+ ))?
+}
+
+#[test]
+fn test_check_withdrawn_status() {
+ assert!(check_withdrawn_status("legal").is_ok());
+ assert!(check_withdrawn_status("withdrawn").is_ok());
+ assert!(check_withdrawn_status("boondogle").is_err());
+ assert!(check_withdrawn_status("").is_err());
+ assert!(check_withdrawn_status("editor ").is_err());
+}
+
pub fn check_contrib_role(raw: &str) -> Result<()> {
let valid_types = vec![
// Citation Style Language official role types
@@ -635,5 +673,3 @@ fn test_check_contrib_role() {
assert!(check_contrib_role("editor ").is_err());
}
-// TODO: make the above checks "more correct"
-// TODO: check ISBN-13