@@ -31,12 +31,12 @@ class ISISInstrumentDataCacheTest : public CxxTest::TestSuite {
31
31
std::string sansJson = R"( {"101115": "2018/RB1800009-2"})" ;
32
32
std::string pg3Json = R"( {"11111": "mock/path"})" ;
33
33
std::string wishJson = R"( {"12345": "subdir1/subdir2"})" ;
34
+ std::string enginxJson = R"( {"55555": "subdir1/subdir2"})" ;
34
35
35
- // Create test JSON file
36
36
std::filesystem::create_directory (m_dataCacheDir);
37
37
38
38
std::unordered_map<std::string, std::string> instrFiles = {
39
- {" MARI" , marJson}, {" SANS2D" , sansJson}, {" POWGEN" , pg3Json}, {" WISH" , wishJson}};
39
+ {" MARI" , marJson}, {" SANS2D" , sansJson}, {" POWGEN" , pg3Json}, {" WISH" , wishJson}, { " ENGINX " , enginxJson} };
40
40
for (const auto &[instrName, instrIndex] : instrFiles) {
41
41
42
42
std::filesystem::create_directory (m_dataCacheDir + " /" + instrName);
@@ -56,26 +56,38 @@ class ISISInstrumentDataCacheTest : public CxxTest::TestSuite {
56
56
void testInstrNameExpanded () {
57
57
ISISInstrumentDataCache dc (m_dataCacheDir);
58
58
std::string actualPath = dc.getFileParentDirectoryPath (" MAR25054" );
59
- TS_ASSERT_EQUALS (actualPath, m_dataCacheDir + " /MARI/2019/RB1868000-1" );
59
+ std::filesystem::path expectedPath = m_dataCacheDir + " /MARI/2019/RB1868000-1" ;
60
+ TS_ASSERT_EQUALS (actualPath, expectedPath.make_preferred ().string ());
60
61
}
61
62
62
63
void testLowerCaseInstrName () {
63
64
ISISInstrumentDataCache dc (m_dataCacheDir);
64
65
std::string actualPath = dc.getFileParentDirectoryPath (" mar25054" );
65
- TS_ASSERT_EQUALS (actualPath, m_dataCacheDir + " /MARI/2019/RB1868000-1" );
66
+ std::filesystem::path expectedPath = m_dataCacheDir + " /MARI/2019/RB1868000-1" ;
67
+ TS_ASSERT_EQUALS (actualPath, expectedPath.make_preferred ().string ());
66
68
}
67
69
68
70
void testCorrectInstrRunSplit () {
69
71
ISISInstrumentDataCache dc (m_dataCacheDir);
70
72
std::string actualPath = dc.getFileParentDirectoryPath (" SANS2D101115" );
71
- TS_ASSERT_EQUALS (actualPath, m_dataCacheDir + " /SANS2D/2018/RB1800009-2" );
73
+ std::filesystem::path expectedPath = m_dataCacheDir + " /SANS2D/2018/RB1800009-2" ;
74
+ TS_ASSERT_EQUALS (actualPath, expectedPath.make_preferred ().string ());
72
75
}
73
76
74
77
void testInstrWithDelimiter () {
75
78
// Checks short name + delimiter gets correctly identified
76
79
ISISInstrumentDataCache dc (m_dataCacheDir);
77
80
std::string actualPath = dc.getFileParentDirectoryPath (" PG3_11111" );
78
- TS_ASSERT_EQUALS (actualPath, m_dataCacheDir + " /POWGEN/mock/path" );
81
+ std::filesystem::path expectedPath = m_dataCacheDir + " /POWGEN/mock/path" ;
82
+ TS_ASSERT_EQUALS (actualPath, expectedPath.make_preferred ().string ());
83
+ }
84
+
85
+ void testShortNameIsTried () {
86
+ // Name ENGIN-X is tried first and if it fails it tries ENGINX
87
+ ISISInstrumentDataCache dc (m_dataCacheDir);
88
+ std::string actualPath = dc.getFileParentDirectoryPath (" ENGINX55555" );
89
+ std::filesystem::path expectedPath = m_dataCacheDir + " /ENGINX/subdir1/subdir2" ;
90
+ TS_ASSERT_EQUALS (actualPath, expectedPath.make_preferred ().string ());
79
91
}
80
92
81
93
void testInstrWithSuffix () {
@@ -106,7 +118,7 @@ class ISISInstrumentDataCacheTest : public CxxTest::TestSuite {
106
118
void testRunNumberNotFound () {
107
119
ISISInstrumentDataCache dc (m_dataCacheDir);
108
120
TS_ASSERT_THROWS_EQUALS (dc.getFileParentDirectoryPath (" SANS2D1234" ), const std::invalid_argument &e,
109
- std::string (e.what ()), " Run number 1234 not found for instrument SANS2D ." );
121
+ std::string (e.what ()), " Run number 1234 not found in index file SANS2D_index.json ." );
110
122
}
111
123
112
124
void testIndexFileExistsWhenExists () {
0 commit comments