MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / TEST_F

Function TEST_F

python/engine/test/PythonEngine_GTest.cpp:44–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42};
43
44TEST_F(PythonEngineFixture, BadMeasure) {
45
46 const std::string classAndDirName = "BadMeasure";
47
48 const auto scriptPath = getScriptPath(classAndDirName);
49 auto measureScriptObject = (*thisEngine)->loadMeasure(scriptPath, classAndDirName);
50 auto* measurePtr = (*thisEngine)->getAs<openstudio::measure::ModelMeasure*>(measureScriptObject);
51
52 ASSERT_EQ(measurePtr->name(), "Bad Measure");
53
54 std::string expected_exception = fmt::format(R"(SWIG director method error. In method 'arguments': `ValueError('oops')`
55
56Traceback (most recent call last):
57 File "{0}", line 22, in arguments
58 self.another_method()
59 File "{0}", line 19, in another_method
60 raise ValueError("oops")
61ValueError: oops)",
62 scriptPath.generic_string());
63
64 openstudio::model::Model model;
65 try {
66 measurePtr->arguments(model);
67 ASSERT_FALSE(true) << "Expected measure arguments(model) to throw";
68 } catch (std::exception& e) {
69 std::string error = e.what();
70 EXPECT_EQ(expected_exception, error);
71 }
72}
73
74TEST_F(PythonEngineFixture, WrongMethodMeasure) {
75

Callers

nothing calls this directly

Calls 9

alfalfaMethod · 0.80
loadMeasureMethod · 0.45
nameMethod · 0.45
argumentsMethod · 0.45
emptyMethod · 0.45
pointsMethod · 0.45
runMethod · 0.45
sizeMethod · 0.45
hasMethodMethod · 0.45

Tested by

no test coverage detected