Skip to content

Commit

Permalink
Add failing test for year 2263
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Dec 7, 2023
1 parent 8bb47f4 commit 84a7d79
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/jobs/csv_export2/test_csvexport2.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import os
import shutil
import subprocess
Expand All @@ -6,6 +7,7 @@
import pandas as pd
import pytest
import rstcheck_core.checker
from resdata.summary import Summary

from semeio.workflows.csv_export2 import csv_export2

Expand Down Expand Up @@ -142,6 +144,44 @@ def test_norne_ensemble_noparams():
)


def test_can_export_summary_files_beyond_2262(tmpdir, monkeypatch):
"""Pandas is/has been eager to use datetime64[ns] which overflows in year 2262,
ensure this limitation is sufficiently worked around."""
monkeypatch.chdir(tmpdir)
res_sum = Summary.from_pandas(
"TESTCASE",
pd.DataFrame(
[
{"DATE": datetime.date(2000, 1, 1), "FPR": 200},
{"DATE": datetime.date(2263, 1, 1), "FPR": 1},
]
).set_index("DATE"),
)

Path("realization-0/iter-0").mkdir(parents=True)
os.chdir("realization-0/iter-0")
# fwrite() can only write to cwd
Summary.fwrite(res_sum)
os.chdir("../..")

Path("runpathfile").write_text(
"0 realization-0/iter-0 TESTCASE 1", encoding="utf-8"
)
csv_export2.csv_exporter(
runpathfile="runpathfile",
time_index="yearly",
outputfile="unsmry--yearly.csv",
column_keys=["FPR"],
)
verify_exported_file(
"unsmry--yearly.csv",
["ENSEMBLE", "REAL", "DATE", "FPR"],
{
("iter-0", 0),
},
)


def verify_exported_file(exported_file_name, result_header, result_iter_rel):
"""Verify an exported CSV file with respect to:
Expand Down

0 comments on commit 84a7d79

Please sign in to comment.