Skip to content

Commit

Permalink
Fix metadata exists (#107)
Browse files Browse the repository at this point in the history
* fix #106 and add relevant tests
  • Loading branch information
Guts committed Sep 25, 2019
1 parent 99bc1a7 commit 029d3b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions isogeo_pysdk/api/routes_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ def exists(self, resource_id: str) -> bool:
else:
pass

# URL builder
url_metadata_exists = "{}{}".format(
utils.get_request_base_url("resources"), resource_id
# request URL
url_metadata_exists = utils.get_request_base_url(
route="resources/{}".format(resource_id)
)

# request
Expand All @@ -269,7 +269,7 @@ def exists(self, resource_id: str) -> bool:
# checking response
req_check = checker.check_api_response(req_metadata_exists)
if isinstance(req_check, tuple):
return req_check
return False

return True

Expand Down
16 changes: 16 additions & 0 deletions tests/test_metadatas.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

# Standard library
import logging
import uuid
import unittest
from os import environ
from pathlib import Path
Expand Down Expand Up @@ -133,7 +134,22 @@ def tearDownClass(cls):
cls.isogeo.close()

# -- TESTS ---------------------------------------------------------
# -- MODEL --

# -- GET --
def test_metadatas_exists(self):
"""GET :resources/{metadata_uuid}"""
# must be true
exists = self.isogeo.metadata.exists(resource_id=self.fixture_metadata._id)
self.assertIsInstance(exists, bool)
self.assertEqual(exists, True)

# must be false
fake_uuid = uuid.uuid4()
exists = self.isogeo.metadata.exists(resource_id=fake_uuid.hex)
self.assertIsInstance(exists, bool)
self.assertEqual(exists, False)

def test_metadatas_in_search_results(self):
"""GET :resources/search"""
search = self.isogeo.search(include="all")
Expand Down

0 comments on commit 029d3b8

Please sign in to comment.