Skip to content
Permalink
Browse files

Update test

  • Loading branch information
nyalldawson committed Jun 16, 2020
1 parent 281356a commit a198e30488d93b94ba0f43d3ec898feea06027da
Showing with 8 additions and 7 deletions.
  1. +8 −7 tests/src/analysis/testqgsprocessing.cpp
// Check variables for child algorithm
// without values
QMap<QString, QgsProcessingModelAlgorithm::VariableDefinition> variables = model2.variablesForChildAlgorithm( "cx1", context );
QCOMPARE( variables.count(), 6 );
QCOMPARE( variables.count(), 7 );
QCOMPARE( variables.value( "DIST" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );
QCOMPARE( variables.value( "CRS" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );
QCOMPARE( variables.value( "SOURCE_LAYER" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );
QCOMPARE( variables.value( "SOURCE_LAYER_minx" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );
QCOMPARE( variables.value( "SOURCE_LAYER_miny" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );

// with values
variables = model2.variablesForChildAlgorithm( "cx1", context, modelInputs, childResults );
QCOMPARE( variables.count(), 6 );
QCOMPARE( variables.count(), 7 );
QCOMPARE( variables.value( "DIST" ).value.toInt(), 271 );
QCOMPARE( variables.value( "SOURCE_LAYER" ).source.parameterName(), QString( "SOURCE_LAYER" ) );
QGSCOMPARENEAR( variables.value( "SOURCE_LAYER_minx" ).value.toDouble(), -118.8888, 0.001 );

std::unique_ptr< QgsExpressionContextScope > childScope( model2.createExpressionContextScopeForChildAlgorithm( "cx1", context, modelInputs, childResults ) );
QCOMPARE( childScope->name(), QStringLiteral( "algorithm_inputs" ) );
QCOMPARE( childScope->variableCount(), 6 );
QCOMPARE( childScope->variableCount(), 7 );
QCOMPARE( childScope->variable( "DIST" ).toInt(), 271 );
QCOMPARE( variables.value( "SOURCE_LAYER" ).source.parameterName(), QString( "SOURCE_LAYER" ) );
QGSCOMPARENEAR( childScope->variable( "SOURCE_LAYER_minx" ).toDouble(), -118.8888, 0.001 );
QCOMPARE( params.count(), 2 );

variables = model2.variablesForChildAlgorithm( "cx2", context );
QCOMPARE( variables.count(), 11 );
QCOMPARE( variables.count(), 12 );
QCOMPARE( variables.value( "DIST" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );
QCOMPARE( variables.value( "SOURCE_LAYER" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );
QCOMPARE( variables.value( "SOURCE_LAYER_minx" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );

// with values
variables = model2.variablesForChildAlgorithm( "cx2", context, modelInputs, childResults );
QCOMPARE( variables.count(), 11 );
QCOMPARE( variables.count(), 12 );
QCOMPARE( variables.value( "DIST" ).value.toInt(), 271 );
QCOMPARE( variables.value( "SOURCE_LAYER" ).source.parameterName(), QString( "SOURCE_LAYER" ) );
QCOMPARE( variables.value( "cx1_OUTPUT" ).source.outputChildId(), QString( "cx1" ) );


variables = model2.variablesForChildAlgorithm( "cx3", context );
QCOMPARE( variables.count(), 16 );
QCOMPARE( variables.count(), 17 );
QCOMPARE( variables.value( "DIST" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );
QCOMPARE( variables.value( "SOURCE_LAYER" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );
QCOMPARE( variables.value( "SOURCE_LAYER_minx" ).source.source(), QgsProcessingModelChildParameterSource::ModelParameter );
QCOMPARE( variables.value( "cx2_OUTPUT_maxy" ).source.outputChildId(), QStringLiteral( "cx2" ) );
// with values
variables = model2.variablesForChildAlgorithm( "cx3", context, modelInputs, childResults );
QCOMPARE( variables.count(), 16 );
QCOMPARE( variables.count(), 17 );
QCOMPARE( variables.value( "DIST" ).value.toInt(), 271 );
QCOMPARE( variables.value( "SOURCE_LAYER" ).source.parameterName(), QString( "SOURCE_LAYER" ) );
QCOMPARE( variables.value( "cx1_OUTPUT" ).source.outputChildId(), QString( "cx1" ) );

0 comments on commit a198e30

Please sign in to comment.
You can’t perform that action at this time.