Skip to content

Commit

Permalink
Merge pull request #23 from OnroerendErfgoed/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
claeyswo authored Jun 10, 2020
2 parents 55ceee8 + 227e749 commit 332aaaa
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 39 deletions.
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ language: python
sudo: false
python:
- "2.7"
- "3.3"
- "3.4"
notifications:
email:
- [email protected]
- [email protected]
- "3.6"
install:
- pip install -r requirements-dev-tci.txt
- pip install -r requirements-dev.txt
- python setup.py develop
script:
py.test --cov storageprovider --cov-report term-missing tests
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

2.5.0 (10/06/2020)
==================

* Lijst met vertaling van id naar bestandsnaam meesturen download zip (#21)

2.4.0 (21/01/2019)
==================

Expand Down
9 changes: 0 additions & 9 deletions requirements-dev-tci.txt

This file was deleted.

30 changes: 22 additions & 8 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# Runtime requirements
--requirement requirements.txt

# pyramid
pyramid-debugtoolbar==4.6.1

# Testing
pytest==2.5.2
pytest-cov==1.6
py==1.4.20
coveralls==0.4.4
mock==1.0.1

#Sphinx
sphinx==1.3.1
pytest==5.4.3; python_version > '3.0'
pytest==4.6.11; python_version < '3.0'
pytest-cov==2.9.0
mock==3.0.5; python_version < '3.0'
tempdir==0.7.1
webtest==2.0.35
coveralls==1.0

# Documentation
Sphinx==3.1.0; python_version > '3.0'
Sphinx==1.8.5; python_version < '3.0'
sphinxcontrib-httpdomain==1.7.0
sphinx_rtd_theme==0.4.3

# waitress
waitress==1.4.4

# Linting
flake8==3.8.3
2 changes: 0 additions & 2 deletions requirements-tci.txt

This file was deleted.

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests==2.3.0
six==1.6.1
requests==2.23.0
six==1.15.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]

setup(name='storageprovider-client',
version='2.4.0',
version='2.5.0',
description='storageprovider client',
long_description=README + '\n\n' + CHANGES,
classifiers=[
Expand Down
17 changes: 11 additions & 6 deletions storageprovider/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,25 @@ def list_object_keys_for_container(self, container_key, system_token=None):
raise InvalidStateException(res.status_code, res.text)
return res.content

def get_container_data(self, container_key, system_token=None):
'''
list all object keys for a container in the data store
def get_container_data(self, container_key, system_token=None, translations=None):
"""
Retrieve a zip of a container in the data store.
:param container_key: key of the container in the data store
:param system_token: oauth system token
:param translations: Dict of object IDs and file names to use for them.
:return list of object keys found in the container
:raises InvalidStateException: if the response is in an invalid state
'''
"""
translations = translations or {}
headers = {'Accept': 'application/zip'}
if system_token:
headers.update({self.system_token_header: system_token})
res = requests.get(self.base_url + '/containers/' + container_key,
headers=headers)
res = requests.get(
self.base_url + '/containers/' + container_key,
params=translations,
headers=headers
)
if res.status_code != 200:
raise InvalidStateException(res.status_code, res.text)
return res.content
Expand Down
24 changes: 20 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,23 @@ def test_list_object_keys_for_container_KO(self, mock_requests):
def test_get_container_data(self, mock_requests):
mock_requests.get.return_value.status_code = 200
self.storageproviderclient.get_container_data(test_container_key)
mock_requests.get.assert_called_with(test_check_url + '/containers/'
+ test_container_key, headers={
'Accept': 'application/zip'})
mock_requests.get.assert_called_with(
test_check_url + '/containers/' + test_container_key,
headers={'Accept': 'application/zip'},
params={}
)

@patch('storageprovider.client.requests')
def test_get_container_data_translations(self, mock_requests):
mock_requests.get.return_value.status_code = 200
self.storageproviderclient.get_container_data(
test_container_key, translations={'001': 'filename.pdf'}
)
mock_requests.get.assert_called_with(
test_check_url + '/containers/' + test_container_key,
headers={'Accept': 'application/zip'},
params={'001': 'filename.pdf'}
)

@patch('storageprovider.client.requests')
def test_get_container_system_token(self, mock_requests):
Expand All @@ -275,7 +289,9 @@ def test_get_container_system_token(self, mock_requests):
"x123-test")
mock_requests.get.assert_called_with(
test_check_url + '/containers/' + test_container_key,
headers={'Accept': 'application/zip', "OpenAmSSOID": "x123-test"})
headers={'Accept': 'application/zip', "OpenAmSSOID": "x123-test"},
params={}
)

@patch('storageprovider.client.requests')
def test_get_container_KO(self, mock_requests):
Expand Down

0 comments on commit 332aaaa

Please sign in to comment.