Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasLiampotis committed Jan 14, 2016
2 parents 153f1db + 6042cd6 commit f804bd0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# B2HANDLE [![Build Status](https://jenkins.argo.grnet.gr/job/B2HANDLE_devel/badge/icon)](https://jenkins.argo.grnet.gr/job/B2HANDLE_devel) ![Test Coverage](http://jenkins.argo.grnet.gr:9913/jenkins/c/http/jenkins.argo.grnet.gr/job/B2HANDLE_devel)
# B2HANDLE [![Build Status](https://jenkins.argo.grnet.gr/job/B2HANDLE_devel/badge/icon)](https://jenkins.argo.grnet.gr/job/B2HANDLE_devel) [![Test Coverage](http://jenkins.argo.grnet.gr:9913/jenkins/c/http/jenkins.argo.grnet.gr/job/B2HANDLE_devel)](https://jenkins.argo.grnet.gr/job/B2HANDLE_devel/cobertura/)


## Docker
Expand Down
22 changes: 10 additions & 12 deletions b2handle/handleclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self, handle_server_url=None, **args):
the reverse lookup base URL to reach the reverse lookup service.
Defaults to '/hrls/handles/'
'''

LOGGER.debug('\n'+60*'*'+'\nInstantialisation with these params:'+\
'\n'+'handle_server_url,'+', '.join(args.keys())+'\n'+60*'*')

Expand All @@ -94,7 +94,6 @@ def __init__(self, handle_server_url=None, **args):
self.__solrurlpath = '/hrls/handles/'
self.__revlookup_auth_string = None
self.__HS_auth_string = None
self.__session = requests.Session()

# Needed for read and or write access:

Expand Down Expand Up @@ -186,7 +185,7 @@ def __init__(self, handle_server_url=None, **args):

if revlookup_user is not None and revlookup_pw is not None:
self.__set_revlookup_auth_string(revlookup_user, revlookup_pw)

LOGGER.debug(' - (end of initialisation)')

@staticmethod
Expand Down Expand Up @@ -845,11 +844,10 @@ def register_handle(self, handle, location, checksum=None, additional_URLs=None,
LOGGER.debug('register_handle...')

# If already exists and can't be overwritten:
if overwrite == False:
handlerecord_json = self.retrieve_handle_record_json(handle)
if handlerecord_json is not None:
msg = 'Could not register handle'
raise HandleAlreadyExistsException(handle, msg)
handlerecord_json = self.retrieve_handle_record_json(handle)
if handlerecord_json is not None and overwrite == False:
msg = 'Could not register handle'
raise HandleAlreadyExistsException(handle, msg)

# Create admin entry
list_of_entries = []
Expand Down Expand Up @@ -1427,7 +1425,7 @@ def __send_handle_delete_request(self, handle, indices=None):
head = self.__get_headers('DELETE')

veri = self.__http_verify
resp = self.__session.delete(url, headers=head, verify=veri)
resp = requests.delete(url, headers=head, verify=veri)
self.__log_request_response_to_file('DELETE', handle, url, head, veri, resp)
return resp

Expand Down Expand Up @@ -1467,7 +1465,7 @@ def __send_handle_put_request(self, handle, list_of_entries, indices=None, overw
LOGGER.debug('PUT Request payload: '+payload)
head = self.__get_headers('PUT')
veri = self.__http_verify
resp = self.__session.put(url, data=payload, headers=head, verify=veri)
resp = requests.put(url, data=payload, headers=head, verify=veri)
self.__log_request_response_to_file('PUT', handle, url, head, veri, resp, payload)
return resp

Expand All @@ -1488,7 +1486,7 @@ def __send_handle_get_request(self, handle, indices=None):
LOGGER.debug('GET Request to '+url)
head = self.__get_headers('GET')
veri = self.__http_verify
resp = self.__session.get(url, headers=head, verify=veri)
resp = requests.get(url, headers=head, verify=veri)
self.__log_request_response_to_file('GET', handle, url, head, veri, resp)
return resp

Expand All @@ -1499,7 +1497,7 @@ def __send_revlookup_get_request(self, query):

head = self.__get_headers('SEARCH')
veri = self.__http_verify
resp = self.__session.get(entirequery, headers=head, verify=veri)
resp = requests.get(entirequery, headers=head, verify=veri)
self.__log_request_response_to_file('SEARCH', '', entirequery, head, veri, resp)
return resp

Expand Down
7 changes: 2 additions & 5 deletions b2handle/tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# vim:set ft=dockerfile:
FROM eudat-b2handle

RUN apt-get update && apt-get install -y --no-install-recommends \
python-coverage \
python-mock \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN easy_install pip
RUN pip install coverage mock

VOLUME /opt/B2HANDLE/b2handle/tests

Expand Down
3 changes: 1 addition & 2 deletions b2handle/tests/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
set -e

if [ "$1" = 'coverage' ]; then
python -m coverage run main_test_script.py
python -m coverage xml --include="*/b2handle/*" --omit="*/tests/*"
nosetests --with-xunit --xunit-testsuite-name=b2handle --cover-erase --cover-tests --cover-inclusive --cover-xml main_test_script.py
else
exec "$@"
fi
6 changes: 3 additions & 3 deletions b2handle/tests/handleclient_writeaccess_patched_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_register_handle(self, getpatch, putpatch):
passed_payload, _ = self.get_payload_headers_from_mockresponse(putpatch)

# Compare with expected payload:
expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "999", "handle": "user/name", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "checksum", "data": "123456"}, {"index": 3, "type": "foo", "data": "foo"}, {"index": 4, "type": "bar", "data": "bar"}, {"index": 5, "type": "10320/LOC", "data": "<locations><location href=\"http://bar.bar\" id=\"0\" /><location href=\"http://foo.foo\" id=\"1\" /></locations>"}]}
expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "999", "handle": "user/name", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "foo", "data": "foo"}, {"index": 4, "type": "bar", "data": "bar"}, {"index": 5, "type": "10320/LOC", "data": "<locations><location href=\"http://bar.bar\" id=\"0\" /><location href=\"http://foo.foo\" id=\"1\" /></locations>"}]}
replace_timestamps(expected_payload)
self.assertEqual(passed_payload, expected_payload,
failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_register_handle_already_exists_overwrite(self, getpatch, putpatch):
passed_payload, passed_headers = self.get_payload_headers_from_mockresponse(putpatch)

# Compare with expected payload:
expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "999", "handle": "user/name", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "checksum", "data": "123456"}, {"index": 3, "type": "foo", "data": "foo"}, {"index": 4, "type": "bar", "data": "bar"}, {"index": 5, "type": "10320/LOC", "data": "<locations><location href=\"http://bar.bar\" id=\"0\" /><location href=\"http://foo.foo\" id=\"1\" /></locations>"}]}
expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "999", "handle": "user/name", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "foo", "data": "foo"}, {"index": 4, "type": "bar", "data": "bar"}, {"index": 5, "type": "10320/LOC", "data": "<locations><location href=\"http://bar.bar\" id=\"0\" /><location href=\"http://foo.foo\" id=\"1\" /></locations>"}]}
replace_timestamps(expected_payload)
self.assertEqual(passed_payload, expected_payload,
failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
Expand Down Expand Up @@ -194,7 +194,7 @@ def test_generate_and_register_handle(self, getpatch, putpatch):
passed_payload, _ = self.get_payload_headers_from_mockresponse(putpatch)

# Compare with expected payload:
expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "999", "handle": "user/name", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "checksum", "data": "123456"}]}
expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "999", "handle": "user/name", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}]}
replace_timestamps(expected_payload)
self.assertEqual(passed_payload, expected_payload,
failure_message(expected=expected_payload, passed=passed_payload, methodname='generate_and_register_handle'))
Expand Down

0 comments on commit f804bd0

Please sign in to comment.