diff --git a/src/pds_doi_service/core/actions/test/update_test.py b/src/pds_doi_service/core/actions/test/update_test.py index 282d14a5..390ce5a7 100644 --- a/src/pds_doi_service/core/actions/test/update_test.py +++ b/src/pds_doi_service/core/actions/test/update_test.py @@ -331,6 +331,11 @@ def test_invalid_update_requests(self): with self.assertRaises(CriticalDOIException): self._update_action.run(**update_kwargs) + #@patch.object( + # + #) + #def test_update_doi(self): + # pass if __name__ == "__main__": unittest.main() diff --git a/src/pds_doi_service/core/actions/update.py b/src/pds_doi_service/core/actions/update.py index 2237e368..144fcdd0 100644 --- a/src/pds_doi_service/core/actions/update.py +++ b/src/pds_doi_service/core/actions/update.py @@ -223,24 +223,23 @@ def _update_dois(self, dois): for updated_doi in dois: if updated_doi.doi: existing_doi = self._get_doi_record_from_doi_identifier(updated_doi.doi) - elif self._force: + else: try: - # try to get DOI from the local database + # try this command first so that it raises an critical exception whatever the force warning status existing_doi = self._get_doi_record_from_pds_identifier(updated_doi.pds_identifier) + if not self._force: + raise WarningDOIException( + f"Record provided for identifier {updated_doi.pds_identifier} does not have a DOI assigned.\n" + "Add it in the Citation_Information/doi tag in the label\n" + " if the version of PDS4 information model you are using allows it.\n" + "Otherwise ignore this warning" + ) except UnknownIdentifierException as e: raise CriticalDOIException( - f"The identifier {updated_doi.pds_identifier} does not have DOI yet" - "use the reserve step to get one" + f"The identifier {updated_doi.pds_identifier} does not have DOI yet." + " Use the reserve step to get one" ) - else: - raise WarningDOIException( - f"Record provided for identifier {updated_doi.pds_identifier} does not have a DOI assigned.\n" - "Add it in the Citation_Information/doi tag in the label\n" - " if the version of PDS4 information model you are using allows it.\n" - "Otherwise ignore this warning" - ) - updated_doi = self._meld_dois(existing_doi, updated_doi) updated_dois.append(updated_doi)