Ejemplo n.º 1
0
def test_read_to_dict_sample_4(backend: PostgresBackend):
    """Is the full dataset correctly read?"""
    reset_test_table(True)
    df = backend.read_to_dict("testdb", sample=4)
    df = pd.DataFrame.from_records(df)
    SampleDataSchema.validate(df)
    assert len(df) == 4
Ejemplo n.º 2
0
def test_read_with_row_filter(df_type, backend: PostgresBackend, filter_expr,
                              expected_data):
    """Is the full dataset correctly read?"""
    reset_test_table(True)
    if df_type == pd.DataFrame:
        df = backend.read_to_pandas("testdb", row_filter=filter_expr)
    elif df_type == dict:
        df = backend.read_to_dict("testdb", row_filter=filter_expr)
    expected_data.assert_correct_and_equal(df)
Ejemplo n.º 3
0
def test_read_to_dict_drop_duplicates(backend: PostgresBackend):
    """Is the full dataset correctly read?"""
    reset_test_table(True)
    df = backend.read_to_dict("testdb", drop_duplicates=True)
    sample_data = SampleDataSet()
    sample_data.first_rows(len(sample_data) - 1).assert_correct_and_equal(df)
Ejemplo n.º 4
0
def test_read_to_dict_top_3(backend: PostgresBackend):
    """Is the full dataset correctly read?"""
    reset_test_table(True)
    df = backend.read_to_dict("testdb", limit=3)
    SampleDataSet().first_rows(3).assert_correct_and_equal(df)
Ejemplo n.º 5
0
def test_read_to_dict_columns(backend: PostgresBackend):
    """Is the full dataset correctly read?"""
    reset_test_table(True)
    df = backend.read_to_dict("testdb", columns=["col_int", "col_string"])
    SampleDataSet().select_columns(
        columns=["col_int", "col_string"]).assert_correct_and_equal(df)
Ejemplo n.º 6
0
def test_read_to_dict_empty_table(backend: PostgresBackend):
    """Try reading an empty table and see if the column names are fetched"""
    df = backend.read_to_dict("empty")
    assert df == dict(col1=[], col2=[])