Skip to content

Commit

Permalink
Merge branch 'hotfix_0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
skasberger committed Apr 6, 2021
2 parents 0d7ea9f + 510d1f9 commit 5747399
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 35 deletions.
7 changes: 3 additions & 4 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ If you are new to open-source development or pyDataverse, we recommend going
through the `GitHub issues <https://github.com/gdcc/pyDataverse/issues>`_,
to find issues that interest you. There are a number of issues listed under
`beginner <https://github.com/gdcc/pyDataverse/labels/info%3Abeginner>`_,
`docs <https://github.com/gdcc/pyDataverse/labels/module%3Adocs>`_,
`good first issue <https://github.com/gdcc/pyDataverse/labels/info%3Agood%20first%20issue>`_
`docs <https://github.com/gdcc/pyDataverse/labels/pkg%3Adocs>`_
and `unassigned issues <https://github.com/gdcc/pyDataverse/issues?q=is%3Aopen++no%3Aassignee+>`_.
where you could start.
Once you've found an interesting issue, you can return here to
Expand Down Expand Up @@ -248,7 +247,7 @@ doesn’t make sense to you, updating the relevant section after you figure
it out is a great way to ensure it will help the next person.

To find ways to contribute to the documentation, start looking the
`docs issues <https://github.com/gdcc/pyDataverse/labels/module%3Adocs>`_.
`docs issues <https://github.com/gdcc/pyDataverse/labels/pkg%3Adocs>`_.


.. _contributing_documentation_about:
Expand Down Expand Up @@ -475,7 +474,7 @@ Like many packages, pyDataverse uses `pytest <https://docs.pytest.org/>`_ and
`tox <https://tox.readthedocs.io/>`_ as test frameworks.

To find open tasks around tests, look at open
`test issues <https://github.com/gdcc/pyDataverse/labels/module%3Atests>`_.
`testing issues <https://github.com/gdcc/pyDataverse/labels/pkg%3Atesting>`_.

**Writing tests**

Expand Down
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. _history:


0.3.1 - (2021-04-06)
----------------------------------------------------------

`Release <https://github.com/gdcc/pyDataverse/releases/tag/0.3.1>`_


0.3.0 - (2021-01-26) - Ruth Wodak
----------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/pyDataverse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
__email__ = "[email protected]"
__copyright__ = "Copyright (c) 2019 Stefan Kasberger"
__license__ = "MIT License"
__version__ = "0.3.0"
__version__ = "0.3.1"
__url__ = "https://github.com/GDCC/pyDataverse"
__download_url__ = "https://pypi.python.org/pypi/pyDataverse"
__description__ = "A Python module for Dataverse."
6 changes: 5 additions & 1 deletion src/pyDataverse/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,11 @@ class Dataset(DVObject):
],
"software": ["softwareName", "softwareVersion"],
"timePeriodCovered": ["timePeriodCoveredStart", "timePeriodCoveredEnd"],
"topicClassification": ["topicClassValue", "topicClassVocab"],
"topicClassification": [
"topicClassValue",
"topicClassVocab",
"topicClassVocabURI",
],
}
__attr_import_dv_up_geospatial_fields_values = ["geographicUnit"]
__attr_import_dv_up_geospatial_fields_arrays = {
Expand Down
58 changes: 29 additions & 29 deletions tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def test_token_missing(self):
BASE_URL = os.getenv("BASE_URL")
api = NativeApi(BASE_URL)
resp = api.get_info_version()
assert resp.json()["data"]["version"] == "4.15.1"
assert resp.json()["data"]["build"] == "1377-701b56b"
assert resp.json()["data"]["version"] == "4.18.1"
assert resp.json()["data"]["build"] == "267-a91d370"

with pytest.raises(ApiAuthorizationError):
ds = Dataset()
Expand All @@ -93,8 +93,8 @@ def test_token_empty_string(self):
BASE_URL = os.getenv("BASE_URL")
api = NativeApi(BASE_URL, "")
resp = api.get_info_version()
assert resp.json()["data"]["version"] == "4.15.1"
assert resp.json()["data"]["build"] == "1377-701b56b"
assert resp.json()["data"]["version"] == "4.18.1"
assert resp.json()["data"]["build"] == "267-a91d370"

with pytest.raises(ApiAuthorizationError):
ds = Dataset()
Expand All @@ -107,36 +107,36 @@ def test_token_empty_string(self):
)
api.create_dataset(":root", ds.json())

def test_token_no_rights(self):
BASE_URL = os.getenv("BASE_URL")
API_TOKEN = os.getenv("API_TOKEN_NO_RIGHTS")
api = NativeApi(BASE_URL, API_TOKEN)
resp = api.get_info_version()
assert resp.json()["data"]["version"] == "4.15.1"
assert resp.json()["data"]["build"] == "1377-701b56b"

with pytest.raises(ApiAuthorizationError):
ds = Dataset()
ds.from_json(
read_file(
os.path.join(
BASE_DIR, "tests/data/dataset_upload_min_default.json"
)
)
)
api.create_dataset(":root", ds.json())
# def test_token_no_rights(self):
# BASE_URL = os.getenv("BASE_URL")
# API_TOKEN = os.getenv("API_TOKEN_NO_RIGHTS")
# api = NativeApi(BASE_URL, API_TOKEN)
# resp = api.get_info_version()
# assert resp.json()["data"]["version"] == "4.18.1"
# assert resp.json()["data"]["build"] == "267-a91d370"

# with pytest.raises(ApiAuthorizationError):
# ds = Dataset()
# ds.from_json(
# read_file(
# os.path.join(
# BASE_DIR, "tests/data/dataset_upload_min_default.json"
# )
# )
# )
# api.create_dataset(":root", ds.json())

def test_token_right_create_dataset_rights(self):
BASE_URL = os.getenv("BASE_URL")
api_su = NativeApi(BASE_URL, os.getenv("API_TOKEN_SUPERUSER"))
api_nru = NativeApi(BASE_URL, os.getenv("API_TOKEN_TEST_NO_RIGHTS"))

resp = api_su.get_info_version()
assert resp.json()["data"]["version"] == "4.15.1"
assert resp.json()["data"]["build"] == "1377-701b56b"
resp = api_nru.get_info_version()
assert resp.json()["data"]["version"] == "4.15.1"
assert resp.json()["data"]["build"] == "1377-701b56b"
assert resp.json()["data"]["version"] == "4.18.1"
assert resp.json()["data"]["build"] == "267-a91d370"
# resp = api_nru.get_info_version()
# assert resp.json()["data"]["version"] == "4.18.1"
# assert resp.json()["data"]["build"] == "267-a91d370"

ds = Dataset()
ds.from_json(
Expand All @@ -148,8 +148,8 @@ def test_token_right_create_dataset_rights(self):
pid = resp.json()["data"]["persistentId"]
assert resp.json()["status"] == "OK"

with pytest.raises(ApiAuthorizationError):
resp = api_nru.get_dataset(pid)
# with pytest.raises(ApiAuthorizationError):
# resp = api_nru.get_dataset(pid)

resp = api_su.delete_dataset(pid)
assert resp.json()["status"] == "OK"
6 changes: 6 additions & 0 deletions tests/data/dataset_upload_full_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@
"multiple": false,
"typeClass": "primitive",
"value": "Topic Classification Vocabulary"
},
"topicClassVocabURI": {
"typeName": "topicClassVocabURI",
"multiple": false,
"typeClass": "primitive",
"value": "https://topic.class/vocab/uri"
}
}
]
Expand Down
3 changes: 3 additions & 0 deletions tests/models/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def dict_flat_set_full():
{
"topicClassValue": "Topic Class Value1",
"topicClassVocab": "Topic Classification Vocabulary",
"topicClassVocabURI": "https://topic.class/vocab/uri",
}
],
"publication": [
Expand Down Expand Up @@ -395,6 +396,7 @@ def object_data_full():
{
"topicClassValue": "Topic Class Value1",
"topicClassVocab": "Topic Classification Vocabulary",
"topicClassVocabURI": "https://topic.class/vocab/uri",
}
],
"publication": [
Expand Down Expand Up @@ -615,6 +617,7 @@ def dict_flat_get_full():
{
"topicClassValue": "Topic Class Value1",
"topicClassVocab": "Topic Classification Vocabulary",
"topicClassVocabURI": "https://topic.class/vocab/uri",
}
],
"publication": [
Expand Down

0 comments on commit 5747399

Please sign in to comment.