mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05:00
#14570 Orion Events: Fix schedule user metadata
This commit is contained in:
1 parent
d6878ea562
commit
e1b192ff86
2 files changed
+38
-1
No files matched your search
@@ -60,8 +60,13 @@ std::expected<QString, QString> RicScheduleDataGenerator::generateSchedule( cons
|
||||
|
||||
// Header
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString userName = environment.value( "USERNAME" );
|
||||
#ifdef Q_OS_WIN
|
||||
QString userName = environment.value( "USERNAME" );
|
||||
if ( userName.isEmpty() ) userName = environment.value( "USER", "unknown" );
|
||||
#else
|
||||
QString userName = environment.value( "USER" );
|
||||
if ( userName.isEmpty() ) userName = environment.value( "USERNAME", "unknown" );
|
||||
#endif
|
||||
|
||||
result += "-- Generated by ResInsight\n";
|
||||
result += QString( "-- Timestamp: %1\n" ).arg( QDateTime::currentDateTimeUtc().toString( Qt::ISODateWithMs ) );
|
||||
|
||||
@@ -1469,6 +1469,38 @@ class TestScheduleGeneration:
|
||||
assert lines[2].startswith("-- User: ")
|
||||
assert lines[2] != "-- User: "
|
||||
|
||||
def test_schedule_header_uses_platform_user_variable(self, monkeypatch):
|
||||
"""Prefer USER on Unix and USERNAME on Windows when both are set."""
|
||||
if sys.platform == "win32":
|
||||
monkeypatch.setenv("USERNAME", "preferred-schedule-user")
|
||||
monkeypatch.setenv("USER", "wrong-schedule-user")
|
||||
else:
|
||||
monkeypatch.setenv("USER", "preferred-schedule-user")
|
||||
monkeypatch.setenv("USERNAME", "wrong-schedule-user")
|
||||
|
||||
instance = rips.Instance.launch(console=True)
|
||||
try:
|
||||
case_root = dataroot.PATH + "/TEST10K_FLT_LGR_NNC"
|
||||
project = instance.project
|
||||
case = project.load_case(path=case_root + "/TEST10K_FLT_LGR_NNC.EGRID")
|
||||
project.import_well_paths(well_path_files=[case_root + "/wellpath_a.dev"])
|
||||
well_path = project.well_paths()[0]
|
||||
timeline = project.descendants(rips.WellPathCollection)[0].event_timeline()
|
||||
timeline.add_perf_event(
|
||||
event_date="2024-01-01",
|
||||
well_path=well_path,
|
||||
start_md=2000.0,
|
||||
end_md=2200.0,
|
||||
diameter=0.1,
|
||||
state="OPEN",
|
||||
)
|
||||
|
||||
schedule = timeline.generate_schedule_text(eclipse_case=case)
|
||||
assert "-- User: preferred-schedule-user\n" in schedule
|
||||
assert "wrong-schedule-user" not in schedule
|
||||
finally:
|
||||
instance.exit()
|
||||
|
||||
def test_event_comment_lines_are_safely_emitted(self, project_with_case_and_well):
|
||||
project, case, timeline = project_with_case_and_well
|
||||
well_path = project.well_paths()[0]
|
||||
|
||||
Reference in new issue
Block a user