MCPcopy Create free account
hub / github.com/Derive-Risk/pyfair / test_inputs

Method test_inputs

tests/model/test_model.py:58–98  ·  view source on GitHub ↗

Check the input methods (leave validation to FairDataInput)

(self)

Source from the content-addressed store, hash-verified

56 model.calculation_completed()
57
58 def test_inputs(self):
59 """Check the input methods (leave validation to FairDataInput)"""
60 # Test basic input
61 model = FairModel('Test', self.N_SAMPLES)
62 model.input_data('Loss Magnitude', constant=100)
63 # Test duplicate inputs passed
64 model.input_data('Loss Magnitude', constant=10)
65 # Test bulk_import_data
66 model.bulk_import_data({
67 'Loss Magnitude': {'constant': 100},
68 'Loss Event Frequency': {'low': 10, 'mode': 15, 'high': 20}
69 })
70 # Test import_multi_data
71 model.input_multi_data('Secondary Loss', {
72 'Reputational': {
73 'Secondary Loss Event Frequency': {'constant': 4000},
74 'Secondary Loss Event Magnitude': {'low': 10, 'mode': 20, 'high': 100},
75 },
76 'Legal': {
77 'Secondary Loss Event Frequency': {'constant': 2000},
78 'Secondary Loss Event Magnitude': {'low': 10, 'mode': 20, 'high': 100},
79 }
80 })
81 # Test input_raw_data
82 model.input_raw_data(
83 'Vulnerability',
84 [1] * self.N_SAMPLES
85 )
86 self.assertRaises(
87 FairException,
88 model.input_raw_data,
89 'Vulnerability',
90 [2] * self.N_SAMPLES
91 )
92 self.assertRaises(
93 FairException,
94 model.input_raw_data,
95 'Vulnerability',
96 'abc'
97 )
98 model.calculate_all()
99
100 def test_calculation(self):
101 """Run a calulate all."""

Callers

nothing calls this directly

Calls 6

input_dataMethod · 0.95
bulk_import_dataMethod · 0.95
input_multi_dataMethod · 0.95
input_raw_dataMethod · 0.95
calculate_allMethod · 0.95
FairModelClass · 0.90

Tested by

no test coverage detected