Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite tests for pack #1593

Merged
merged 5 commits into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions tests/unit/archiving/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pyiron_base import Project
from pyiron_base.project.archiving.export_archive import export_database, copy_h5_files
import pandas as pd
from pandas._testing import assert_frame_equal
from filecmp import dircmp
import shutil
from pyiron_base._tests import PyironTestCase, ToyJob
Expand All @@ -20,8 +19,8 @@ def setUpClass(cls):
cls.arch_dir_comp = cls.arch_dir + "_comp"
cls.pr = Project("test")
cls.pr.remove_jobs(recursive=True, silently=True)
cls.job = cls.pr.create_job(job_type=ToyJob, job_name="toy")
cls.job.run()
job = cls.pr.create_job(job_type=ToyJob, job_name="toy")
job.run()
cls.pr.pack(destination_path=cls.arch_dir, compress=False)
cls.file_location = os.path.dirname(os.path.abspath(__file__)).replace(
"\\", "/"
Expand All @@ -39,18 +38,12 @@ def test_exportedCSV(self):
# in the first test, the csv file from the packing function is read
# and is compared with the return dataframe from export_database
directory_to_transfer = os.path.basename(self.pr.path[:-1])
self.pr.pack(destination_path=self.arch_dir, compress=False)
df_read = pd.read_csv("export.csv")
df_read.drop(df_read.keys()[0], inplace=True, axis=1)
# this removes the "None/NaN/empty" cells as well as the unnamed column
df_read.dropna(inplace=True, axis=1)
df_read["timestart"] = pd.to_datetime(df_read["timestart"])
df_read["hamversion"] = float(df_read["hamversion"])
df_exp = export_database(
self.pr, directory_to_transfer, "archive_folder"
).dropna(axis=1)
df_exp["hamversion"] = float(df_exp["hamversion"])
assert_frame_equal(df_exp, df_read)
self.assertEqual(df_exp["job"].unique()[0], "toy")
self.assertEqual(df_exp["id"].unique()[0], 0)

def test_HDF5(self):
# first we check whether the toy.h5 file exists
Expand Down
Loading