def test_elastic_mapping(self): """ Test the elastic_mapping class method """ url = "http://127.0.0.1:9200/pacifica/_mapping/ElasticAPI" obj = ElasticAPI() obj.id = 127 response_body = { "status": "mapped!" } httpretty.register_uri(httpretty.PUT, url, body=dumps(response_body), content_type="application/json") ElasticAPI.create_elastic_mapping() self.assertEqual(httpretty.last_request().method, "PUT")
def test_failed_elastic_mapping(self): """ Test the elastic mapping class method failed upload """ url = "http://127.0.0.1:9200/pacifica/_mapping/ElasticAPI" obj = ElasticAPI() obj.id = 127 response_body = { "status": "error!" } httpretty.register_uri(httpretty.PUT, url, body=dumps(response_body), content_type="application/json", status=500) #pylint: disable=broad-except try: ElasticAPI.create_elastic_mapping() except Exception, ex: self.assertEqual(httpretty.last_request().method, "PUT") self.assertEqual(str(ex), "create_elastic_mapping: 500\n")