ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
testDaqContext.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_ocm_libdaq_test
4  * @copyright 2022 ESO - European Southern Observatory
5  *
6  * @brief Test daq::Status and daq::ObservableStatus
7  */
8 #include <gtest/gtest.h>
9 #include <gmock/gmock.h>
10 #include <daq/daqContext.hpp>
11 
12 using namespace ::testing;
13 
14 namespace daq {
15 
16 TEST(TestDaqContext, Files) {
17  DaqContext ctx;
18 
19  EXPECT_TRUE(ctx.results.empty());
20 
21  std::vector<DpPart> files1{{"origin1", "path1"}, {"origin2", "path2"} };
22  std::vector<DpPart> files2{{"origin3", "path3"}};
23 
24  AddDpParts(ctx, files1);
25  EXPECT_FALSE(ctx.results.empty());
26  EXPECT_EQ(files1, ctx.results);
27  EXPECT_NE(files2, ctx.results);
28 
29  AddDpParts(ctx, files2);
30  EXPECT_NE(files1, ctx.results);
31 
32  auto files3 = files1;
33  files3.insert(files3.end(), files2.begin(), files2.end());
34  EXPECT_EQ(files3, ctx.results);
35 }
36 
37 TEST(TestDaqContext, Keywords) {
38  DaqContext ctx;
39 
40  EXPECT_TRUE(ctx.keywords.empty());
41 
43  UpdateKeywords(ctx, v);
44  EXPECT_TRUE(ctx.keywords.empty());
45 
46  v.push_back(fits::EsoKeyword("FOO", "EsoKeyword"));
47  UpdateKeywords(ctx, v);
48  EXPECT_EQ(v, ctx.keywords);
49 
50  v.push_back(fits::ValueKeyword("FOO", "ValueKeyword"));
51  UpdateKeywords(ctx, v);
52  EXPECT_EQ(v, ctx.keywords) << "Expected both keywords to be there";
53 
54  fits::EsoKeyword new_foo = fits::EsoKeyword("FOO", true);
55  UpdateKeywords(ctx, { new_foo });
56  v[0] = new_foo;
57  EXPECT_EQ(v, ctx.keywords);
58 }
59 
60 } // namespace daq
daq::TEST
TEST(TestDaqContext, Files)
Definition: testDaqContext.cpp:16
daq::fits::EsoKeyword
BasicKeyword< EsoKeywordTraits > EsoKeyword
ESO hiearchical keyword.
Definition: keyword.hpp:337
daq
Definition: asyncProcess.cpp:15
daq::DaqContext::results
DpParts results
Results from Data Acquisition (FITS files and keywords).
Definition: daqContext.hpp:106
daq::fits::BasicKeyword
A type safe version of LiteralKeyword that consist of the three basic components of a FITS keyword ke...
Definition: keyword.hpp:266
daq::DaqContext
Structure carrying context needed to start a Data Acquisition and construct a Data Product Specificat...
Definition: daqContext.hpp:48
daq::DaqContext::keywords
std::vector< daq::fits::KeywordVariant > keywords
Keyword list provided by OCM to Data Product.
Definition: daqContext.hpp:91
daqContext.hpp
Contains declaration of daq::Context.
daq::fits::KeywordVector
std::vector< KeywordVariant > KeywordVector
Vector of keywords.
Definition: keyword.hpp:414
daq::AddDpParts
void AddDpParts(DaqContext &ctx, std::vector< DpPart > const &parts)
Definition: daqContext.cpp:35
daq::UpdateKeywords
void UpdateKeywords(DaqContext &ctx, fits::KeywordVector const &keywords)
Updates (adds or replaces) primary HDU keywords.
Definition: daqContext.cpp:28