def test_without_item_count(self): base_url = "http://api.semantica.dev.globoi.com" param_dict = {"do_item_count": "0", "per_page": "30", "page": "0"} handler = MockHandler(uri=base_url) params = ParamDict(handler, **param_dict) computed = list_all_contexts(params) self.assertTrue("item_count" not in computed)
def test_no_context_found(self, mock1): param_dict = {"per_page": "3", "page": "1"} base_url = "http://api.semantica.dev.globoi.com" handler = MockHandler(uri=base_url) params = ParamDict(handler, **param_dict) result = list_all_contexts(params) self.assertEqual(result["items"], [])
def test_list_contexts(self): param_dict = {"per_page": "30", "page": "0"} base_url = "http://api.semantica.dev.globoi.com" handler = MockHandler(uri=base_url) params = ParamDict(handler, **param_dict) computed = list_all_contexts(params) expected_items = [ {'@id': 'http://dbpedia.org/ontology/', 'title': 'dbpedia', 'resource_id': 'dbpedia'} ] self.assertEqual(computed["items"], expected_items)
def test_raises_http_error_invalid_page(self, mock1, mock2, mock3): handler = MockHandler() params = ParamDict(handler, page='100') result = list_all_contexts(params) self.assertEqual(result["items"], [])
def test_raises_http_error(self, mock1, mock2, mock3): result = list_all_contexts(Params({})) self.assertEqual(result["items"], [])