コード例 #1
0
 def test_constrain_num_gates(self):
     """Checks the case of the constrained number of gates."""
     self.factors.set_gate_weights([1, 1, 1, 0.1, 0.1])
     self.factors.num_basic = 200
     self.factors.constrain_num_gate(200)
     self.factors.calculate()
     fault_tree = generate_fault_tree("TestingTree", "root", self.factors)
     assert_is_not_none(fault_tree)
     assert_less(abs(1 - len(fault_tree.gates) / 200), 0.1)
コード例 #2
0
 def test_constrain_num_gates(self):
     """Checks the case of the constrained number of gates."""
     self.factors.set_gate_weights([1, 1, 1, 0.1, 0.1])
     self.factors.num_basic = 200
     self.factors.constrain_num_gate(200)
     self.factors.calculate()
     fault_tree = generate_fault_tree("TestingTree", "root", self.factors)
     assert fault_tree is not None
     assert abs(1 - len(fault_tree.gates) / 200) < 0.1
コード例 #3
0
 def test_aralia_output(self):
     """Checks if the Aralia format output passes validation."""
     self.factors.set_gate_weights([1, 1, 1, 0.1, 0.1])
     self.factors.num_house = 10
     self.factors.num_ccf = 10
     self.factors.calculate()
     fault_tree = generate_fault_tree("TestingTree", "root", self.factors)
     assert_is_not_none(fault_tree)
     self.output.write(fault_tree.to_aralia())
     self.output.file.flush()
     tmp = NamedTemporaryFile(mode="w+")
     cmd = ["./translators/aralia.py", self.output.name, "-o", tmp.name]
     assert_equal(0, call(cmd))
コード例 #4
0
 def test_aralia_output(self):
     """Checks if the Aralia format output passes validation."""
     self.factors.set_gate_weights([1, 1, 1, 0.1, 0.1])
     self.factors.num_house = 10
     self.factors.num_ccf = 10
     self.factors.calculate()
     fault_tree = generate_fault_tree("TestingTree", "root", self.factors)
     assert fault_tree is not None
     self.output.write(fault_tree.to_aralia())
     self.output.file.flush()
     tmp = NamedTemporaryFile(mode="w+")
     cmd = ["./translators/aralia.py", self.output.name, "-o", tmp.name]
     assert call(cmd) == 0
コード例 #5
0
 def test_xml_output(self):
     """Checks if the XML output passes the schema validation."""
     self.factors.set_gate_weights([1, 1, 1, 0.1, 0.1])
     self.factors.num_house = 10
     self.factors.num_ccf = 10
     self.factors.calculate()
     fault_tree = generate_fault_tree("TestingTree", "root", self.factors)
     assert_is_not_none(fault_tree)
     write_info(fault_tree, self.output, 123)
     write_summary(fault_tree, self.output)
     self.output.write(fault_tree.to_xml(1))
     self.output.flush()
     relaxng_doc = etree.parse("../share/input.rng")
     relaxng = etree.RelaxNG(relaxng_doc)
     with open(self.output.name, "r") as test_file:
         doc = etree.parse(test_file)
         assert_true(relaxng.validate(doc))
コード例 #6
0
 def test_xml_output(self):
     """Checks if the XML output passes the schema validation."""
     self.factors.set_gate_weights([1, 1, 1, 0.1, 0.1])
     self.factors.num_house = 10
     self.factors.num_ccf = 10
     self.factors.calculate()
     fault_tree = generate_fault_tree("TestingTree", "root", self.factors)
     assert fault_tree is not None
     write_info(fault_tree, self.output, 123)
     write_summary(fault_tree, self.output)
     self.output.write(fault_tree.to_xml(1))
     self.output.flush()
     relaxng_doc = etree.parse("../share/input.rng")
     relaxng = etree.RelaxNG(relaxng_doc)
     with open(self.output.name, "r") as test_file:
         doc = etree.parse(test_file)
         assert relaxng.validate(doc)