コード例 #1
0
    def test_save_and_load(self, dummy_dataframe, filepath):
        """Test saving and reloading the data set."""
        excel_dataset, excel_df = setup_excel_dataset(filepath)
        appendable_excel_dataset = AppendableExcelDataSet(
            filepath=filepath,
            load_args={"sheet_name": "test"},
            save_args={"sheet_name": "test"},
        )
        appendable_excel_dataset.save(dummy_dataframe)
        reloaded = appendable_excel_dataset.load()
        assert_frame_equal(dummy_dataframe, reloaded)

        reloaded_first_sheet = excel_dataset.load()
        assert_frame_equal(reloaded_first_sheet, excel_df)

        assert appendable_excel_dataset._save_args == {
            "index": False,
            "sheet_name": "test",
        }
        assert appendable_excel_dataset._load_args == {
            "engine": "openpyxl",
            "sheet_name": "test",
        }
        assert appendable_excel_dataset._writer_args == {
            "engine": "openpyxl",
            "mode": "a",
        }
コード例 #2
0
 def test_exists(self, filepath):
     """Test `exists` method invocation for both existing and
     nonexistent data set."""
     appendable_excel_dataset = AppendableExcelDataSet(filepath)
     assert not appendable_excel_dataset.exists()
     setup_excel_dataset(filepath)
     assert appendable_excel_dataset.exists()
コード例 #3
0
def appendable_excel_dataset(filepath, save_args, load_args):
    return AppendableExcelDataSet(filepath=filepath,
                                  load_args=load_args,
                                  save_args=save_args)