Skip to content

Commit

Permalink
Better error message when DOI was not generated by GitHub
Browse files Browse the repository at this point in the history
Refs #8
  • Loading branch information
sverhoeven committed Jul 5, 2018
1 parent 99d08d3 commit 9482c0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions doi2cff/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def init(doi, cff_fn):
zenodo_record = fetch_zenodo_by_doiurl(doi)

if not is_software_zenodo(zenodo_record):
raise NotImplemented('Unable to process doi, converter not implemented for zenodo entries other than software')
raise NotImplemented('Unable to process doi, converter not implemented for Zenodo entries other than software')

yaml = ruamel.yaml.YAML()
data = yaml.load(template)
Expand Down Expand Up @@ -121,7 +121,7 @@ def tagurl_of_zenodo(record):
if related_identifier['relation'] == 'isSupplementTo':

return related_identifier['identifier']
raise KeyError('Zenodo record does not contain a related identifier with isSupplementTo relation ')
raise KeyError('Unable to process DOI, Zenodo record does not contain a related identifier with isSupplementTo relation, which is expected for DOI generated by GitHub')


def tagurl2repo(tagurl):
Expand Down
9 changes: 5 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from io import FileIO, StringIO

import pytest
import yaml

from click.testing import CliRunner
import requests_mock
Expand Down Expand Up @@ -43,7 +44,7 @@ def test_init(runner, zenodo_1200251, cff_1200251):
result = f.read()

expected = cff_1200251
assert result == expected
assert yaml.load(result) == yaml.load(expected)


def test_update_version(cff_1194353, zenodo_1200251, cff_1194353_updated_1200251):
Expand All @@ -60,7 +61,7 @@ def test_update_version(cff_1194353, zenodo_1200251, cff_1194353_updated_1200251
result = f.getvalue()

expected = cff_1194353_updated_1200251
assert result == expected
assert yaml.load(result) == yaml.load(expected)


def test_init_withzenodoref(runner, zenodo_1197761, zenodo_1200251, cff_1197761):
Expand All @@ -76,7 +77,7 @@ def test_init_withzenodoref(runner, zenodo_1197761, zenodo_1200251, cff_1197761)
result = f.read()

expected = cff_1197761
assert result == expected
assert yaml.load(result) == yaml.load(expected)


def test_init_withnonzenodoref(runner, zenodo_58369, cslfor_58369, cff_58369):
Expand All @@ -92,4 +93,4 @@ def test_init_withnonzenodoref(runner, zenodo_58369, cslfor_58369, cff_58369):
result = f.read()

expected = cff_58369
assert result == expected
assert yaml.load(result) == yaml.load(expected)

0 comments on commit 9482c0f

Please sign in to comment.