mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
#14636 Orion Events: List COMMENT as valid item name
COMMENT is accepted on all keywords and is stored on the event instead of being passed as keyword data, so it is not part of the item names reported by opm-common. The validation error listed only the opm-common items, giving no hint that COMMENT is allowed when a user mistyped it as COMMENTS. Append COMMENT to the list of valid item names in the error message. Only the diagnostic is affected, COMMENT is still handled as event metadata.
This commit is contained in:
committed by
Magne Sjaastad
parent
1336eba81d
commit
98e39bc02f
@@ -74,6 +74,12 @@ std::expected<void, QString> validateKeywordItems( const QString& keywordName, c
|
||||
validNames.push_back( itemName );
|
||||
}
|
||||
|
||||
// COMMENT is accepted on all keywords. It is stored on the event and emitted as a schedule comment instead of being
|
||||
// passed as keyword data, so it is not part of the item names reported by opm-common. Include it in the list of
|
||||
// valid names to help spot typos like COMMENTS.
|
||||
const QString commentItemName( "COMMENT" );
|
||||
if ( !validNames.contains( commentItemName ) ) validNames.push_back( commentItemName );
|
||||
|
||||
return std::unexpected( QString( "Keyword '%1' contains invalid item names: %2. Valid item names are: %3." )
|
||||
.arg( keywordName.toUpper(), invalidNames.join( ", " ), validNames.join( ", " ) ) );
|
||||
}
|
||||
|
||||
@@ -1889,6 +1889,49 @@ class TestOrionEventsIntegration:
|
||||
)
|
||||
assert "Valid item names are:" in error_msg
|
||||
|
||||
def test_comment_is_listed_as_valid_item_name(self, project_with_case_and_wells):
|
||||
"""COMMENT is accepted on every keyword, so it must be suggested when the user
|
||||
mistypes it, e.g. as COMMENTS (issue #14636)."""
|
||||
project, _case, timeline = project_with_case_and_wells
|
||||
well = project.well_paths()[0]
|
||||
document = parse_orion_events(
|
||||
"ORIONEVENTS 2.0\n"
|
||||
f'WELL "{well.name}"\n'
|
||||
" 2018-06-08 WTRACER TRACER=T1 CONCENTRATION=1.0 COMMENTS=typo\n"
|
||||
)
|
||||
|
||||
report = apply_orion_document(document, timeline, project)
|
||||
|
||||
assert report.events_applied == 0
|
||||
assert report.events_skipped == 1
|
||||
assert len(report.errors) == 1
|
||||
error_msg = report.errors[0]
|
||||
assert "Keyword 'WTRACER' contains invalid item names: COMMENTS" in error_msg
|
||||
|
||||
valid_names = error_msg.split("Valid item names are:")[1]
|
||||
assert "COMMENT" in valid_names
|
||||
# COMMENT must be listed once, in addition to the opm-common item names.
|
||||
assert [name.strip(" .") for name in valid_names.split(",")].count(
|
||||
"COMMENT"
|
||||
) == 1
|
||||
|
||||
def test_comment_attribute_is_accepted_on_keyword_event(
|
||||
self, project_with_case_and_wells
|
||||
):
|
||||
"""COMMENT must stay event metadata and not be rejected as an invalid item name."""
|
||||
project, _case, timeline = project_with_case_and_wells
|
||||
well = project.well_paths()[0]
|
||||
document = parse_orion_events(
|
||||
"ORIONEVENTS 2.0\n"
|
||||
f'WELL "{well.name}"\n'
|
||||
' 2018-06-08 WTRACER TRACER=T1 CONCENTRATION=1.0 COMMENT="Tracer start"\n'
|
||||
)
|
||||
|
||||
report = apply_orion_document(document, timeline, project)
|
||||
|
||||
assert report.errors == []
|
||||
assert report.events_applied == 1
|
||||
|
||||
def test_unknown_keyword_reports_context_and_continues(
|
||||
self, project_with_case_and_wells
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user