Skip to content

Commit

Permalink
Remove base_uri from RegistryResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Van Daele committed May 20, 2015
1 parent 9a91923 commit 2c1dd3d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
7 changes: 2 additions & 5 deletions pyramid_urireferencer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import json

class RegistryResponse:
def __init__(self, uri, base_uri, success, has_references, count, applications):
def __init__(self, uri, success, has_references, count, applications):
self.uri = uri
self.base_uri = base_uri
self.success = success
self.has_references = has_references
self.count = count
Expand All @@ -17,7 +16,6 @@ def __json__(self, request):
{
'success': self.success,
'has_references': self.has_references,
'base_uri': self.base_uri,
'count': self.count,
'applications': self.applications
}
Expand All @@ -32,12 +30,11 @@ def __eq__(self, other):
@staticmethod
def load_from_json(data):
try:
r = RegistryResponse(None, None, None, None, None, None)
r = RegistryResponse(None, None, None, None, None)
if isinstance(data, str):
data = json.loads(data)
response = data['response']
r.uri = data['request']['uri']
r.base_uri = response['base_uri']
r.success = response['success']
r.has_references = response['has_references']
r.count = response['count']
Expand Down
2 changes: 1 addition & 1 deletion pyramid_urireferencer/referencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ def is_referenced(self, uri):
r = requests.get(url)
return RegistryResponse.load_from_json(r.json())
except:
return RegistryResponse(uri, None, False, None, None, None)
return RegistryResponse(uri, False, None, None, None)


3 changes: 1 addition & 2 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ def test_add_referencer(self):

def test_is_referenced(self):
uri = 'http://id.erfgoed.net/foobar/2'
base_uri = 'http://id.erfgoed.net/foobar'
url = 'http://localhost:6543'
reg_response_success_ref1 = RegistryResponse(uri, base_uri, True, False, 0, []).__json__(None)
reg_response_success_ref1 = RegistryResponse(uri, True, False, 0, []).__json__(None)

referencer = TestReferencer(url)
self.assertIsNone(referencer.references(uri))
Expand Down

0 comments on commit 2c1dd3d

Please sign in to comment.