/
test_report.py
131 lines (108 loc) · 4.96 KB
/
test_report.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright 2019 TerraPower, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Really basic tests of the report Utils"""
import logging
import unittest
from armi import runLog, settings
from armi.bookkeeping import report
from armi.bookkeeping.report import data, reportInterface
from armi.bookkeeping.report.reportingUtils import (
makeBlockDesignReport,
setNeutronBalancesReport,
summarizePinDesign,
summarizePower,
summarizePowerPeaking,
summarizeZones,
writeAssemblyMassSummary,
writeCycleSummary,
)
from armi.reactor.tests.test_reactors import loadTestReactor
from armi.tests import mockRunLogs
class TestReport(unittest.TestCase):
def setUp(self):
self.test_group = data.Table(settings.getMasterCs(), "banana")
def test_setData(self):
report.setData("banana_1", ["sundae", "plain"])
report.setData("banana_2", ["sundae", "vanilla"], self.test_group)
report.setData(
"banana_3", ["sundae", "chocolate"], self.test_group, [report.ALL]
)
with self.assertRaises(AttributeError):
report.setData(
"banana_4", ["sundae", "strawberry"], "no_workie", [report.ALL]
)
with self.assertRaises(AttributeError):
report.setData(
"banana_5", ["sundae", "peanut_butter"], self.test_group, "no_workie"
)
ungroup_instance = report.ALL[report.UNGROUPED]
self.assertEqual(ungroup_instance["banana_1"], ["sundae", "plain"])
filled_instance = report.ALL[self.test_group]
self.assertEqual(filled_instance["banana_2"], ["sundae", "vanilla"])
self.assertEqual(filled_instance["banana_3"], ["sundae", "chocolate"])
def test_printReports(self):
"""testing printReports method"""
repInt = reportInterface.ReportInterface(None, None)
rep = repInt.printReports()
self.assertIn("REPORTS BEGIN", rep)
self.assertIn("REPORTS END", rep)
def test_writeReports(self):
"""Test writing html reports."""
repInt = reportInterface.ReportInterface(None, None)
repInt.writeReports()
def test_reactorSpecificReporting(self):
"""Test a number of reporting utils that require reactor/core information"""
o, r = loadTestReactor()
with mockRunLogs.BufferLog() as mock:
# we should start with a clean slate
self.assertEqual("", mock._outputStream)
runLog.LOG.startLog("test_reactorSpecificReporting")
runLog.LOG.setVerbosity(logging.INFO)
writeAssemblyMassSummary(r)
self.assertIn("BOL Assembly Mass Summary", mock._outputStream)
self.assertIn("igniter fuel", mock._outputStream)
self.assertIn("primary control", mock._outputStream)
self.assertIn("plenum", mock._outputStream)
mock._outputStream = ""
setNeutronBalancesReport(r.core)
self.assertIn("No rate information", mock._outputStream)
mock._outputStream = ""
summarizePinDesign(r.core)
self.assertIn("Assembly Design Summary", mock._outputStream)
self.assertIn("Design & component information", mock._outputStream)
self.assertIn("Multiplicity", mock._outputStream)
mock._outputStream = ""
summarizePower(r.core)
self.assertIn("Power in radial shield", mock._outputStream)
self.assertIn("Power in primary control", mock._outputStream)
self.assertIn("Power in feed fuel", mock._outputStream)
mock._outputStream = ""
writeCycleSummary(r.core)
self.assertIn("Core Average", mock._outputStream)
self.assertIn("Outlet Temp", mock._outputStream)
self.assertIn("End of Cycle", mock._outputStream)
mock._outputStream = ""
# this report won't do much for the test reactor - improve test reactor
summarizeZones(r.core, o.cs)
self.assertTrue(len(mock._outputStream) == 0)
mock._outputStream = ""
# this report won't do much for the test reactor - improve test reactor
makeBlockDesignReport(r)
self.assertTrue(len(mock._outputStream) == 0)
mock._outputStream = ""
# this report won't do much for the test reactor - improve test reactor
summarizePowerPeaking(r.core)
self.assertTrue(len(mock._outputStream) == 0)
if __name__ == "__main__":
unittest.main()