Skip to content

Commit

Permalink
testing keywords filter on specific md
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Apr 2, 2018
1 parent 1be24ee commit d9774b9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/test_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ def test_check_filter_sub_resources_ok(self):
# metadata sub resources
subresources = checker._check_filter_sub_resources(sub_resources="all",
resource="metadata")
self.assertIsInstance(subresources, str)
self.assertIsInstance(subresources, string_types)
# keyword sub resources
subresources = checker._check_filter_sub_resources(sub_resources="all",
resource="keyword")
self.assertIsInstance(subresources, str)
self.assertIsInstance(subresources, string_types)

def test_check_filter_sub_resources_bad(self):
"""Raise errors"""
Expand Down
37 changes: 37 additions & 0 deletions tests/test_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,43 @@ def test_keywords_subresources_bad(self):
)

# specific md
def test_search_specifc_mds_ok(self):
"""Searches filtering on specific metadata."""
# get random metadata within a small search
search_10 = self.isogeo.search(self.bearer,
page_size=10,
whole_share=0)
md_a, md_b = search_10.get("results")[randint(0, 5)].get("_id"),\
search_10.get("results")[randint(6, 9)].get("_id")
md_bad = "trust_me_this_is_a_good_uuid"
# get random metadata within a small search
search_ids_1 = self.isogeo.keywords(self.bearer,
specific_md=[md_a, ],
page_size=1)
search_ids_2 = self.isogeo.keywords(self.bearer,
specific_md=[md_a, md_b],
page_size=1)
search_ids_3 = self.isogeo.keywords(self.bearer,
specific_md=[md_a, md_b, md_bad],
page_size=1)
# test type
self.assertIsInstance(search_ids_1, dict)
self.assertIsInstance(search_ids_2, dict)
self.assertIsInstance(search_ids_3, dict)

def test_search_specifc_mds_bad(self):
"""Searches filtering on specific metadata."""
# get random metadata within a small search
search_5 = self.isogeo.search(self.bearer,
page_size=5,
whole_share=0)
md = search_5.get("results")[randint(0, 4)].get("_id")
# pass metadata UUID
with self.assertRaises(TypeError):
self.isogeo.search(self.bearer,
page_size=0,
whole_share=0,
specific_md=md)

# specific tag

Expand Down

0 comments on commit d9774b9

Please sign in to comment.