ifw-daq  3.0.0-pre2
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
Contains declaration of daq::Context.
std::vector< KeywordVariant > KeywordVector
Vector of keywords.
Definition: keyword.hpp:414
BasicKeyword< EsoKeywordTraits > EsoKeyword
ESO hiearchical keyword.
Definition: keyword.hpp:337
void UpdateKeywords(DaqContext &ctx, fits::KeywordVector const &keywords)
Updates (adds or replaces) primary HDU keywords.
Definition: daqContext.cpp:29
void AddDpParts(DaqContext &ctx, std::vector< DpPart > const &parts)
Definition: daqContext.cpp:36
TEST(TestDaqContext, Files)
Structure carrying context needed to start a Data Acquisition and construct a Data Product Specificat...
Definition: daqContext.hpp:44
DpParts results
Results from Data Acquisition (FITS files and keywords).
Definition: daqContext.hpp:102
std::vector< daq::fits::KeywordVariant > keywords
Keyword list provided by OCM to Data Product.
Definition: daqContext.hpp:87
A type safe version of LiteralKeyword that consist of the three basic components of a FITS keyword ke...
Definition: keyword.hpp:266
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")