IODA Bundle
TestBufrDescription.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 NOAA/NWS/NCEP/EMC
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #pragma once
9 
10 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
11 
12 #include <iomanip>
13 #include <iostream>
14 #include <memory>
15 #include <set>
16 #include <string>
17 #include <vector>
18 
19 #include "eckit/config/LocalConfiguration.h"
20 #include "eckit/testing/Test.h"
21 #include "oops/runs/Test.h"
22 #include "oops/test/TestEnvironment.h"
23 #include "oops/util/Expect.h"
24 #include "oops/util/IntSetParser.h"
25 
29 
30 
31 namespace Ingester
32 {
33  namespace test
34  {
36  {
37  const eckit::LocalConfiguration conf(::test::TestEnvironment::config());
38 
39  if (conf.has("observations"))
40  {
41  for (const auto &obsConf : conf.getSubConfigurations("observations"))
42  {
43  if (obsConf.has("obs space") &&
44  obsConf.getSubConfiguration("obs space").has("name") &&
45  obsConf.getSubConfiguration("obs space").getString("name") == "bufr")
46  {
47  auto bufrConf = obsConf.getSubConfiguration("obs space");
48  auto description = Ingester::BufrDescription(bufrConf);
49 
50  EXPECT(description.getMnemonicSets().size() > 0);
51  EXPECT(description.getExport().getVariables().size() > 0);
52  }
53  else
54  {
55  throw eckit::BadValue(
56  "Configuration File is missing the \"bufr\" section.");
57  }
58 
59  if (obsConf.has("ioda"))
60  {
61  auto iodaConf = obsConf.getSubConfiguration("ioda");
62  auto description = Ingester::IodaDescription(iodaConf);
63 
64  EXPECT(description.getDims().size() > 0);
65  EXPECT(description.getVariables().size() > 0);
66  }
67  else
68  {
69  throw eckit::BadValue(
70  "Configuration File is missing the \"ioda\" section.");
71  }
72  }
73  }
74  }
75 
76  class BufrDescription : public oops::Test
77  {
78  public:
79  BufrDescription() = default;
80  virtual ~BufrDescription() = default;
81  private:
82  std::string testid() const override { return "ingester::test::BufrParser"; }
83  void register_tests() const override
84  {
85  std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
86 
87  ts.emplace_back(CASE("ingester/BufrParser/testConstructor")
88  {
90  });
91  }
92 
93  void clear() const override
94  {
95  }
96  };
97  } // namespace test
98 } // namespace Ingester
Description of the data to be read from a BUFR file and how to expose that data to the outside world.
Describes how to write data to IODA.
void register_tests() const override
virtual ~BufrDescription()=default
std::string testid() const override
static const eckit::Configuration & config()
CASE("Validation")