mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
Python: Reject summary writes for unsupported case types
This commit is contained in:
1 parent
ef1ad39723
commit
f32d59775b
2 files changed
+40
-20
No files matched your search
@@ -244,34 +244,38 @@ std::expected<caf::PdmObjectHandle*, QString> RimSummaryCase_setSummaryVectorVal
|
||||
{
|
||||
auto* summaryCase = self<RimSummaryCase>();
|
||||
auto* fileSummaryCase = dynamic_cast<RimFileSummaryCase*>( summaryCase );
|
||||
if ( fileSummaryCase )
|
||||
if ( !fileSummaryCase )
|
||||
{
|
||||
bool rebuildUserInterface = true;
|
||||
return std::unexpected( QString( "Setting summary values is not supported for summary case type '%1'. "
|
||||
"Only file-backed summary cases support user-defined vectors." )
|
||||
.arg( summaryCase->classKeyword() ) );
|
||||
}
|
||||
|
||||
if ( auto reader = fileSummaryCase->summaryReader() )
|
||||
bool rebuildUserInterface = true;
|
||||
|
||||
if ( auto reader = fileSummaryCase->summaryReader() )
|
||||
{
|
||||
auto allAddr = reader->allResultAddresses();
|
||||
for ( const auto& adr : allAddr )
|
||||
{
|
||||
auto allAddr = reader->allResultAddresses();
|
||||
for ( auto adr : allAddr )
|
||||
if ( adr.uiText() == m_addressString().toStdString() )
|
||||
{
|
||||
if ( adr.uiText() == m_addressString().toStdString() )
|
||||
{
|
||||
rebuildUserInterface = false;
|
||||
break;
|
||||
}
|
||||
rebuildUserInterface = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto result = fileSummaryCase->setSummaryData( m_addressString().toStdString(), m_unitString().toStdString(), m_values() );
|
||||
if ( !result.has_value() )
|
||||
{
|
||||
return std::unexpected( result.error() );
|
||||
}
|
||||
auto result = fileSummaryCase->setSummaryData( m_addressString().toStdString(), m_unitString().toStdString(), m_values() );
|
||||
if ( !result.has_value() )
|
||||
{
|
||||
return std::unexpected( result.error() );
|
||||
}
|
||||
|
||||
if ( rebuildUserInterface )
|
||||
{
|
||||
fileSummaryCase->buildTreeNodesIfRequired();
|
||||
fileSummaryCase->updateConnectedEditors();
|
||||
}
|
||||
if ( rebuildUserInterface )
|
||||
{
|
||||
fileSummaryCase->buildTreeNodesIfRequired();
|
||||
fileSummaryCase->updateConnectedEditors();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RigCaseRealizationParameters.h"
|
||||
#include "RimcSummaryCase.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// RimSummaryCase interface tests
|
||||
@@ -33,6 +34,21 @@ TEST( RimMockSummaryCase, SummaryReaderReturnsSelf )
|
||||
EXPECT_EQ( static_cast<RifSummaryReaderInterface*>( &mockCase ), mockCase.summaryReader() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RimMockSummaryCase, SetSummaryValuesReturnsErrorForUnsupportedCaseType )
|
||||
{
|
||||
RimMockSummaryCase mockCase;
|
||||
RimSummaryCase_setSummaryVectorValues method( &mockCase );
|
||||
|
||||
auto result = method.execute();
|
||||
|
||||
ASSERT_FALSE( result.has_value() );
|
||||
EXPECT_TRUE( result.error().contains( "not supported" ) );
|
||||
EXPECT_TRUE( result.error().contains( "Only file-backed summary cases" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// RifSummaryReaderInterface tests
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user