def test_add_create_index_with_mapping(): es = ES(None, 'datagouvfr_test-index-mapping', mapping) assert not elastic.indices.exists(index = 'datagouvfr_test-index-mapping-2020-01-01') es.add({"day": "2020-01-01"}) es.commit() assert elastic.indices.exists(index = 'datagouvfr_test-index-mapping-2020-01-01') assert mapping['mappings'] == elastic.indices.get(index = 'datagouvfr_test-index-mapping-2020-01-01')['datagouvfr_test-index-mapping-2020-01-01']['mappings']
def test_es_add(): es = ES(None, 'datagouvfr_test-add', mapping) assert not elastic.indices.exists(index = 'datagouvfr_test-add-2020-01-01') es.add({"hello": "world", "day": "2020-01-01"}) es.commit() assert elastic.indices.exists(index = 'datagouvfr_test-add-2020-01-01') time.sleep(1) data = elastic.search(index = 'datagouvfr_test-add-2020-01-01') assert len(data['hits']['hits']) == 1