Skip to content

Commit

Permalink
COMP: Ensure DICOM Query, Retrieve and Schedule tests use a different DB
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Jan 18, 2024
1 parent d5806e9 commit d51bccd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
17 changes: 11 additions & 6 deletions Libs/DICOM/Core/Testing/Cpp/ctkDICOMQueryTest2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
#include <QCoreApplication>
#include <QDebug>
#include <QStringList>
#include <QTemporaryDir>
#include <QVariant>

// ctkCore includes
#include <ctkCoreTestingMacros.h>

// ctkDICOMCore includes
#include "ctkDICOMDatabase.h"
#include "ctkDICOMQuery.h"
Expand All @@ -48,17 +52,18 @@ int ctkDICOMQueryTest2( int argc, char * argv [] )
return EXIT_FAILURE;
}

QTemporaryDir tempDirectory;
CHECK_BOOL(tempDirectory.isValid(), true);

ctkDICOMTester tester;
tester.startDCMQRSCP();
tester.storeData(arguments);

ctkDICOMDatabase database;
QString dbFile = "./ctkDICOM.sql";
if (!database.openDatabase(dbFile))
{
std::cout << "ctkDICOMDatabase::openDatabase() failed" << std::endl;
return EXIT_FAILURE;
}

QDir databaseDirectory(tempDirectory.path());
QString dbFile = QFileInfo(databaseDirectory, QString("ctkDICOM.sql")).absoluteFilePath();
CHECK_BOOL(database.openDatabase(dbFile), true);
database.cleanup(true);

ctkDICOMQuery query;
Expand Down
17 changes: 11 additions & 6 deletions Libs/DICOM/Core/Testing/Cpp/ctkDICOMRetrieveTest2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
#include <QPair>
#include <QString>
#include <QStringList>
#include <QTemporaryDir>
#include <QVariant>

// ctkCore includes
#include <ctkCoreTestingMacros.h>

// ctkDICOMCore includes
#include "ctkDICOMDatabase.h"
#include "ctkDICOMQuery.h"
Expand All @@ -51,6 +55,9 @@ int ctkDICOMRetrieveTest2( int argc, char * argv [] )
return EXIT_FAILURE;
}

QTemporaryDir tempDirectory;
CHECK_BOOL(tempDirectory.isValid(), true);

ctkDICOMTester tester;
std::cerr << "ctkDICOMRetrieveTest2: Starting dcmqrscp\n";
tester.startDCMQRSCP();
Expand All @@ -59,12 +66,10 @@ int ctkDICOMRetrieveTest2( int argc, char * argv [] )
tester.storeData(arguments);

ctkDICOMDatabase database;
QString dbFile = "./ctkDICOM.sql";
if (!database.openDatabase(dbFile))
{
std::cout << "ctkDICOMDatabase::openDatabase() failed" << std::endl;
return EXIT_FAILURE;
}

QDir databaseDirectory(tempDirectory.path());
QString dbFile = QFileInfo(databaseDirectory, QString("ctkDICOM.sql")).absoluteFilePath();
CHECK_BOOL(database.openDatabase(dbFile), true);
database.cleanup(true);

std::cerr << "ctkDICOMRetrieveTest2: Setting up query\n";
Expand Down
15 changes: 9 additions & 6 deletions Libs/DICOM/Core/Testing/Cpp/ctkDICOMSchedulerTest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

// Qt includes
#include <QCoreApplication>
#include <QTemporaryDir>

// ctkCore includes
#include "ctkCoreTestingMacros.h"
#include <ctkCoreTestingMacros.h>

// ctkDICOMCore includes
#include "ctkDICOMScheduler.h"
Expand All @@ -47,6 +48,9 @@ int ctkDICOMSchedulerTest1(int argc, char * argv []) {
return EXIT_FAILURE;
}

QTemporaryDir tempDirectory;
CHECK_BOOL(tempDirectory.isValid(), true);

int numberOfImages = arguments.count();

ctkDICOMTester tester;
Expand Down Expand Up @@ -78,14 +82,13 @@ int ctkDICOMSchedulerTest1(int argc, char * argv []) {
// Test scheduler
std::cout << qPrintable(testName) << ": Setting up scheduler" << std::endl;
ctkDICOMDatabase database;
QString dbFile = "./ctkDICOM.sql";
QFile file(dbFile);
file.remove();
QFile cacheFile("./ctkDICOMTagCache.sql");
cacheFile.remove();

QDir databaseDirectory(tempDirectory.path());
QString dbFile = QFileInfo(databaseDirectory, QString("ctkDICOM.sql")).absoluteFilePath();
CHECK_BOOL(database.openDatabase(dbFile), true);
CHECK_BOOL(database.isOpen(), true);
database.cleanup(true);

CHECK_INT(database.patients().count(), 0);

scheduler.setDicomDatabase(database);
Expand Down

0 comments on commit d51bccd

Please sign in to comment.