def test_save_and_load_catalog(data_set, dummy_dataframe, tmpdir):
    catalog = DataCatalogWithDefault(data_sets={"test": data_set}, default=default_csv)

    path = str(tmpdir.mkdir("sub").join("test"))
    catalog.save(path, dummy_dataframe)
    reloaded_df = catalog.load(path)
    assert dummy_dataframe.equals(reloaded_df)
def test_load_from_unregistered(dummy_dataframe, tmpdir):
    catalog = DataCatalogWithDefault(data_sets={}, default=default_csv)

    path = str(tmpdir.mkdir("sub").join("test.csv"))
    catalog.save(path, dummy_dataframe)
    reloaded_df = catalog.load(path)

    assert dummy_dataframe.equals(reloaded_df)
def test_remember_save(tmpdir, dummy_dataframe):
    catalog = DataCatalogWithDefault(data_sets={},
                                     default=default_csv,
                                     remember=True)

    path = str(tmpdir.mkdir("sub").join("test.csv"))
    catalog.save(path, dummy_dataframe)
    assert tmpdir.join("sub").join("test.csv") in catalog.list()
def test_default_none():
    with pytest.raises(
            TypeError,
            match="Default must be a callable with a "
            "single input string argument: the "
            "key of the requested data set.",
    ):
        DataCatalogWithDefault(data_sets={}, default=None)
def test_remember_load():
    catalog = DataCatalogWithDefault(data_sets={},
                                     default=default_memory,
                                     remember=True)
    assert catalog.load("any") == 5
    assert "any" in catalog.list()