def test_read(engine): source = ElasticSearchTableSource('score:[0 TO 150]', **CONNECT) out = source.read() # this would be easier with a full query with sorting assert all([ d in out.to_dict(orient='records') for d in df.to_dict(orient='records') ])
def test_close(engine): source = ElasticSearchTableSource('score:[0 TO 150]', qargs={"sort": 'rank'}, **CONNECT) source.close() # Can reopen after close out = source.read() assert out[df.columns].equals(df)
def test_discover_after_read(engine): source = ElasticSearchTableSource('score:[0 TO 150]', **CONNECT) info = source.discover() dt = {k: str(v) for k, v in df.dtypes.to_dict().items()} assert info['dtype'] == dt assert info['shape'] == (None, 3) assert info['npartitions'] == 1 out = source.read() assert all([d in out.to_dict(orient='records') for d in df.to_dict(orient='records')]) info = source.discover() assert info['dtype'] == dt assert info['shape'] == (4, 3) assert info['npartitions'] == 1