Skip to content

Commit

Permalink
added error tests for jigsaw (#4093)
Browse files Browse the repository at this point in the history
* added error tests

* added some other error tests

* added last test

* addressed comments

* missed a thing

* removed useless test
  • Loading branch information
Kelvin Rodriguez authored Oct 30, 2020
1 parent bee0df2 commit 24e277c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 85 deletions.
3 changes: 0 additions & 3 deletions isis/src/control/apps/jigsaw/jigsaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ namespace Isis {
QString cubeList = ui.GetFileName("FROMLIST");

// retrieve settings from jigsaw gui

BundleSettingsQsp settings = bundleSettings(ui);
settings->setCubeList(cubeList);
BundleAdjust *bundleAdjustment = NULL;
Expand All @@ -73,7 +72,6 @@ namespace Isis {
throw;
}


// Bundle adjust the network
try {

Expand Down Expand Up @@ -103,7 +101,6 @@ namespace Isis {
bundleAdjustment->controlNet()->Write(ui.GetFileName("ONET"));

PvlGroup gp("JigsawResults");

// Update the cube pointing if requested but ONLY if bundle has converged
if (ui.GetBoolean("UPDATE") ) {
if ( !bundleAdjustment->isConverged() ) {
Expand Down
78 changes: 0 additions & 78 deletions isis/src/control/apps/jigsaw/tsts/errors/Makefile

This file was deleted.

84 changes: 80 additions & 4 deletions isis/tests/FunctionalTestsJigsaw.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include "Fixtures.h"
#include "Pvl.h"
#include "PvlGroup.h"
#include "TestUtilities.h"
#include "ControlNet.h"
#include "Statistics.h"

#include "jigsaw.h"

#include "gtest/gtest.h"
#include "TestUtilities.h"
#include "Fixtures.h"
#include "gmock/gmock.h"

using namespace Isis;
using namespace testing;


static QString APP_XML = FileName("$ISISROOT/bin/xml/jigsaw.xml").expanded();

Expand Down Expand Up @@ -143,4 +145,78 @@ TEST_F(ObservationPair, FunctionalTestJigsawCamSolveAll) {
// DEC(t3) final
EXPECT_NEAR(elems.at(56).toDouble(), 0.365717165, 0.00001);

}
}

TEST_F(ObservationPair, FunctionalTestJigsawErrorNoSolve) {
QTemporaryDir prefix;
QString outCnetFileName = prefix.path() + "/outTemp.net";
QVector<QString> args = {"fromlist="+cubeListFile, "cnet="+cnetPath, "onet="+outCnetFileName,
"camsolve=None", "spsolve=None"};

UserInterface options(APP_XML, args);

Pvl log;

try {
jigsaw(options, &log);
FAIL() << "Should throw" << std::endl;
}
catch (IException &e) {
EXPECT_THAT(e.what(), HasSubstr("Must either solve for camera pointing or spacecraft position"));
}
}


TEST_F(ObservationPair, FunctionalTestJigsawErrorTBParamsNoTarget) {
QTemporaryDir prefix;
QString outCnetFileName = prefix.path() + "/outTemp.net";

// just use isdPath for a valid PVL file without the wanted groups
QVector<QString> args = {"fromlist="+cubeListFile, "cnet="+cnetPath, "onet="+outCnetFileName, "SOLVETARGETBODY=TRUE", "tbparameters="+cubeRPath};

UserInterface options(APP_XML, args);

Pvl log;

try {
jigsaw(options, &log);
FAIL() << "Should throw an exception" << std::endl;
}
catch (IException &e) {
EXPECT_THAT(e.what(), HasSubstr("Input Target parameters file missing main Target object"));
}
}


TEST_F(ObservationPair, FunctionalTestJigsawErrorTBParamsNoSolve) {
QTemporaryDir prefix;
QString outCnetFileName = prefix.path() + "/outTemp.net";

std::istringstream iss(R"(
Object = Target
Group = "NAME"
Name=Enceladus
EndGroup
END_OBJECT
)");

QString tbsolvepath = prefix.path() + "/tbsolve.pvl";
Pvl tbsolve;
iss >> tbsolve;
tbsolve.write(tbsolvepath);

// just use isdPath for a valid PVL file without the wanted groups
QVector<QString> args = {"fromlist="+cubeListFile, "cnet="+cnetPath, "onet="+outCnetFileName, "SOLVETARGETBODY=TRUE", "tbparameters="+tbsolvepath};

UserInterface options(APP_XML, args);

Pvl log;

try {
jigsaw(options, &log);
FAIL() << "Should throw an exception" << std::endl;
}
catch (IException &e) {
EXPECT_THAT(e.what(), HasSubstr("Must solve for at least one target body option"));
}
}

0 comments on commit 24e277c

Please sign in to comment.