def test_elastic_connect(self): """Test the create elastic index.""" response_body = {} httpretty.register_uri(httpretty.GET, 'http://127.0.0.1:9200/', body=dumps(response_body), content_type='application/json') try_es_connect() self.assertEqual(httpretty.last_request().method, 'GET')
def create_tables(): """Create the tables for the objects if they exist.""" try_db_connect() try_es_connect() create_elastic_index() for obj in ORM_OBJECTS: if not obj.table_exists(): obj.create_table() obj.create_elastic_mapping() DB.close()
def test_elastic_connect(self): """ Test the create elastic index """ response_body = {} httpretty.register_uri(httpretty.GET, "http://127.0.0.1:9200/_stats", body=dumps(response_body), content_type="application/json") try_es_connect() self.assertEqual(httpretty.last_request().method, "GET")
def create_tables(): """ Create the tables for the objects if they exist. """ try_db_connect() try_es_connect() create_elastic_index() for obj in ORM_OBJECTS: if not obj.table_exists(): obj.create_table() obj.create_elastic_mapping() DB.close()
def test_error_es_connect(self): """ Test the create elastic index """ httpretty.register_uri(httpretty.GET, "http://127.0.0.1:9200/_stats", body="Trying to connect", status=404) #pylint: disable=broad-except try: try_es_connect() except Exception, ex: self.assertEqual(httpretty.last_request().method, "GET") self.assertEqual(str(ex), "try_es_connect: 404\n")
def test_error_es_connect(self): """Test the create elastic index.""" hit_exception = False httpretty.register_uri(httpretty.GET, 'http://127.0.0.1:9200/', body='Trying to connect', status=404) # pylint: disable=broad-except try: try_es_connect() except Exception as ex: hit_exception = True self.assertEqual(httpretty.last_request().method, 'GET') self.assertEqual(str(ex), 'TransportError(404, u\'Trying to connect\')') # pylint: enable=broad-except self.assertTrue(hit_exception)