Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelvinrr committed Oct 25, 2024
1 parent 3d48f52 commit f758a9c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
6 changes: 3 additions & 3 deletions SpiceQL/db/lro.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"moc" : {
"ck" : {
"reconstructed" : {
"kernels": ["moc42r_[0-9]{7}_[0-9]{7}_v[0-9]{2}.bc$"]
"kernels": ["moc42r?_[0-9]{7}_[0-9]{7}_v[0-9]{2}.bc$"]
}
},
"spk" : {
"reconstructed" : {
"kernels" : ["fdf29r_[0-9]{7}_[0-9]{7}_[nbv][0-9]{2}.bsp$"]
"kernels" : ["fdf29r?_[0-9]{7}_[0-9]{7}_[nbv][0-9]{2}.bsp$"]
},
"smithed" : {
"kernels" : ["LRO_.*_GRGM660.*.bsp$", "LRO_.*_GRGM900C.*.BSP$"]
Expand All @@ -36,7 +36,7 @@
}
},
"tspk" : {
"kernels" : ["^de421.bsp$", "moon_pa_de421_1900-2050.bpc$"]
"kernels" : ["de421.bsp$", "moon_pa_de421_1900-2050.bpc$"]
},
"ik" : {
"kernels" : ["lro_lroc_v[0-9]{2}.ti$"]
Expand Down
3 changes: 1 addition & 2 deletions SpiceQL/src/spice_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ namespace SpiceQL {
return static_cast<Kernel::Quality>(res.second);
}

std::string qualities = std::accumulate(Kernel::QUALITIES.begin(), Kernel::QUALITIES.end(), std::string(", "));
throw invalid_argument(fmt::format("{} is not a valid kernel type, available types are: {}", qa, qualities));
throw invalid_argument(fmt::format("{} is not a valid kernel type, available types are: {}", qa, fmt::join(Kernel::QUALITIES, ", ")));
}


Expand Down
12 changes: 7 additions & 5 deletions SpiceQL/tests/Fixtures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ void TempTestingFiles::SetUp() {


void TempTestingFiles::TearDown() {
// if(!fs::remove_all(tempDir)) {
// throw runtime_error("Could not delete temporary files");
// }
if(!fs::remove_all(tempDir)) {
throw runtime_error("Could not delete temporary files");
}
}


Expand Down Expand Up @@ -273,9 +273,11 @@ void LroKernelSet::SetUp() {
writeSpk(spkPath3, positions, times1, bodyCode/1000, 301, referenceFrame, "SPK ID 3", 1, velocities, "SPK 3");

// Write IK1 -------------------------------------------
fs::create_directory(root / "iak");
fs::create_directory(root / "ik");


ikPath1 = root / "ik" / "lro_instruments_v10.ti";
ikPath1 = root / "iak" / "lro_instrumentAddendum_v11.ti";
nlohmann::json jKeywords = {
{"INS-85600_PIXEL_SAMPLES", { 5064 }},
{"INS-85600_PIXEL_LINES", { 1 }},
Expand All @@ -286,7 +288,7 @@ void LroKernelSet::SetUp() {
writeTextKernel(ikPath1, "ik", jKeywords);

// Write IK2 -------------------------------------------
ikPath2 = root / "ik" / "lro_instruments_v11.ti";
ikPath2 = root / "ik" / "lro_lroc_v11.ti";
jKeywords = {
{"INS-85600_PIXEL_SAMPLES", { 5063 }},
{"INS-85600_PIXEL_LINES", { 1 }},
Expand Down
4 changes: 2 additions & 2 deletions SpiceQL/tests/FunctionalTestsSpiceQueries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ using namespace SpiceQL;

TEST_F(LroKernelSet, FunctionalTestSearchMissionKernels) {
// do a time query
nlohmann::json kernels = Inventory::search_for_kernelset("lroc", {"lsk", "sclk", "ck", "spk", "ik", "fk"}, 110000000, 140000001);
nlohmann::json kernels = Inventory::search_for_kernelset("lroc", {"lsk", "sclk", "ck", "spk", "iak", "fk"}, 110000000, 140000001);
cout << kernels.dump(4) << endl;
ASSERT_EQ(kernels["ck"].size(), 2);
EXPECT_EQ(fs::path(kernels["ck"][0].get<string>()).filename(), "soc31_1111111_1111111_v21.bc" );
EXPECT_EQ(fs::path(kernels["ik"][0].get<string>()).filename(), "lro_instruments_v11.ti");
EXPECT_EQ(fs::path(kernels["iak"][0].get<string>()).filename(), "lro_instrumentAddendum_v11.ti");
EXPECT_EQ(fs::path(kernels["fk"][0].get<string>()).filename(), "lro_frames_1111111_v01.tf");
EXPECT_EQ(fs::path(kernels["sclk"][0].get<string>()).filename(), "lro_clkcor_2020184_v00.tsc");
}
2 changes: 1 addition & 1 deletion SpiceQL/tests/KernelTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ TEST_F(LroKernelSet, UnitTestFindMissionKeywords) {
nlohmann::json keywords = findMissionKeywords("INS-85600_CCD_CENTER", "lro");

nlohmann::json expectedResults;
expectedResults["INS-85600_CCD_CENTER"] = {2531.3, 0.4};
expectedResults["INS-85600_CCD_CENTER"] = {2531.5, 0.5};

EXPECT_EQ(keywords, expectedResults);
}
Expand Down
15 changes: 8 additions & 7 deletions SpiceQL/tests/QueryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,41 +231,42 @@ TEST_F(IsisDataDirectory, FunctionalTestLroConf) {
mocks.OnCallFunc(ls).Return(files);

nlohmann::json res = listMissionKernels("doesn't matter", conf);

SPDLOG_DEBUG("Kernel Results: {}", res.dump(4));
// check a kernel from each regex exists in their quality groups
vector<string> kernelToCheck = SpiceQL::getKernelsAsVector(res.at("moc").at("ck").at("reconstructed").at("kernels"));
vector<string> expected = {"moc42r_2016305_2016336_v01.bc"};

SPDLOG_DEBUG("Checking CKs");
for (auto &e : expected) {
auto it = find(kernelToCheck.begin(), kernelToCheck.end(), e);
if (it == kernelToCheck.end()) {
FAIL() << e << " was not found in the kernel results";
throw runtime_error(e+" was not found in the kernel results");
}
}

SPDLOG_DEBUG("Checking Recon SPKs");
kernelToCheck = getKernelsAsVector(res.at("moc").at("spk").at("reconstructed"));
expected = {"fdf29r_2018305_2018335_v01.bsp", "fdf29_2021327_2021328_b01.bsp"};
for (auto &e : expected) {
auto it = find(kernelToCheck.begin(), kernelToCheck.end(), e);
if (it == kernelToCheck.end()) {
FAIL() << e << " was not found in the kernel results";
throw runtime_error(e+" was not found in the kernel results");
}
}


SPDLOG_DEBUG("Checking Smithed SPKs");
kernelToCheck = getKernelsAsVector(res.at("moc").at("spk").at("smithed"));
expected = {"LRO_ES_05_201308_GRGM660PRIMAT270.bsp", "LRO_ES_16_201406_GRGM900C_L600.BSP"};
for (auto &e : expected) {
auto it = find(kernelToCheck.begin(), kernelToCheck.end(), e);
if (it == kernelToCheck.end()) {
FAIL() << e << " was not found in the kernel results";
throw runtime_error(e+" was not found in the kernel results");
}
}

SPDLOG_DEBUG("Checking IAKs");
kernelToCheck = getKernelsAsVector(res.at("minirf").at("iak"));
expected = {"mrflroAddendum002.ti"};
EXPECT_EQ(kernelToCheck, expected);

}


Expand Down
2 changes: 1 addition & 1 deletion bindings/python/tests/test_pyspiceql.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def test_jsonConversion():
lro_config = getMissionConfig('lro')
assert isinstance(lro_config, dict)
kernel_list = lro_config["lro"]["ik"]["kernels"]
kernel_list = lro_config["lro"]["iak"]["kernels"]
assert isinstance(kernel_list, list)

def test_config():
Expand Down

0 comments on commit f758a9c

Please sign in to comment.