Skip to content

Commit

Permalink
test: update tests for recursive hazard rates
Browse files Browse the repository at this point in the history
  • Loading branch information
weibullguy committed Feb 20, 2022
1 parent 7438425 commit f1e18e2
Show file tree
Hide file tree
Showing 7 changed files with 365 additions and 313 deletions.
5 changes: 5 additions & 0 deletions tests/__data/test_program_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ INSERT INTO "ramstk_design_electric" VALUES(1,4,0,0.0,0.0,0,0,0,0,0,0.0,0.0,0.0,
INSERT INTO "ramstk_design_electric" VALUES(1,5,0,0.0,0.0,0,0,0,0,0,0.0,0.0,0.0,0,0,0,0.0,0.0,0,0,0,0,0,1,0,0,0,0,0.0,0,0,0.0,0.0,0.0,'',0.0,0,0,35.0,0.0,25.0,0.0,0.0,25.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,1);
INSERT INTO "ramstk_design_electric" VALUES(1,6,0,0.0,0.0,0,0,0,0,0,0.0,0.0,0.0,0,0,0,0.0,0.0,0,0,0,0,0,1,0,0,0,0,0.0,0,0,0.0,0.0,0.0,'',0.0,0,0,35.0,0.0,25.0,0.0,0.0,25.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,1);
INSERT INTO "ramstk_design_electric" VALUES(1,7,0,0.0,0.0,0,0,0,0,0,0.0,0.0,0.0,0,0,0,0.0,0.0,0,0,0,0,0,1,0,0,0,0,0.0,0,0,0.0,0.0,0.0,'',0.0,0,0,35.0,0.0,25.0,0.0,0.0,25.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,1);
INSERT INTO "ramstk_design_electric" VALUES(1,8,0,0.0,0.0,0,0,0,0,0,0.0,0.0,0.0,0,0,0,0.0,0.0,0,0,0,0,0,1,0,0,0,0,0.0,0,0,0.0,0.0,0.0,'',0.0,0,0,35.0,0.0,25.0,0.0,0.0,25.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,1);
CREATE TABLE ramstk_design_mechanic (
fld_revision_id INTEGER NOT NULL,
fld_hardware_id INTEGER NOT NULL,
Expand Down Expand Up @@ -502,6 +503,7 @@ INSERT INTO "ramstk_design_mechanic" VALUES(1,4,0.0,0,0,0.0,0,0.0,0.0,0.0,0.0,0.
INSERT INTO "ramstk_design_mechanic" VALUES(1,5,0.0,0,0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0,0.0,0,0,0,0.0,0.0,0,0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0,0.0,0,0,0.0,0.0,0.0,0.0);
INSERT INTO "ramstk_design_mechanic" VALUES(1,6,0.0,0,0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0,0.0,0,0,0,0.0,0.0,0,0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0,0.0,0,0,0.0,0.0,0.0,0.0);
INSERT INTO "ramstk_design_mechanic" VALUES(1,7,0.0,0,0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0,0.0,0,0,0,0.0,0.0,0,0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0,0.0,0,0,0.0,0.0,0.0,0.0);
INSERT INTO "ramstk_design_mechanic" VALUES(1,8,0.0,0,0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0,0.0,0,0,0,0.0,0.0,0,0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0,0.0,0,0,0.0,0.0,0.0,0.0);
CREATE TABLE ramstk_mil_hdbk_f (
fld_revision_id INTEGER NOT NULL,
fld_hardware_id INTEGER NOT NULL,
Expand Down Expand Up @@ -550,6 +552,7 @@ INSERT INTO "ramstk_mil_hdbk_f" VALUES(1,4,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0
INSERT INTO "ramstk_mil_hdbk_f" VALUES(1,5,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
INSERT INTO "ramstk_mil_hdbk_f" VALUES(1,6,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
INSERT INTO "ramstk_mil_hdbk_f" VALUES(1,7,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
INSERT INTO "ramstk_mil_hdbk_f" VALUES(1,8,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
CREATE TABLE ramstk_nswc (
fld_revision_id INTEGER NOT NULL,
fld_hardware_id INTEGER NOT NULL,
Expand Down Expand Up @@ -620,6 +623,7 @@ INSERT INTO "ramstk_nswc" VALUES(1,4,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
INSERT INTO "ramstk_nswc" VALUES(1,5,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0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and Down Expand Up @@ -673,6 +677,7 @@ INSERT INTO "ramstk_reliability" VALUES(1,4,0.0,1.0,1.0,0.0,0.0,0,0.0,0.0,0.0,0,
INSERT INTO "ramstk_reliability" VALUES(1,5,0.0,1.0,1.0,0.0,0.0,0,0.0,0.0035,0.0,0,0.0,'',0.0,0.0,0.15,2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.0,0,1.0,1.0,0.0,0.0,0.0,0.0,0);
INSERT INTO "ramstk_reliability" VALUES(1,6,0.0,1.0,1.0,0.0,0.0,0,2.89e-06,0.0,0.0,0,0.0,'',0.0,2.3,0.045,2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0,0.9995,0,1.0,1.0,0.0,0.0,0.0,0.0,0);
INSERT INTO "ramstk_reliability" VALUES(1,7,0.0,1.0,1.0,0.0,0.0,0,1.132e-07,0.0,0.0,0,0.0,'',0.0,0.0,0.0,3,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,89560.0,0.0,0.0,0.0,1.0,0,0.0,0,1.0,1.0,0.0,0.0,0.0,0.0,0);
INSERT INTO "ramstk_reliability" VALUES(1,8,0.0,1.0,1.0,0.0,0.0,0,1.132e-07,0.0,0.0,0,0.0,'',0.0,0.0,0.0,3,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,89560.0,0.0,0.0,0.0,1.0,0,0.0,0,1.0,1.0,0.0,0.0,0.0,0.0,0);
CREATE TABLE ramstk_similar_item (
fld_revision_id INTEGER NOT NULL,
fld_hardware_id INTEGER NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class TestInsertMethods:
def on_succeed_insert_sibling(self, tree):
assert isinstance(tree, Tree)
assert isinstance(
tree.get_node(8).data["design_electric"], RAMSTKDesignElectricRecord
tree.get_node(9).data["design_electric"], RAMSTKDesignElectricRecord
)
assert tree.get_node(8).data["design_electric"].hardware_id == 8
assert tree.get_node(9).data["design_electric"].hardware_id == 9
print("\033[36m\nsucceed_insert_design_electric topic was broadcast.")

def on_fail_insert_no_hardware(self, error_message):
Expand All @@ -86,22 +86,23 @@ def on_fail_insert_no_hardware(self, error_message):
"\033[35m\nfail_insert_design_electric topic was broadcast on no hardware."
)

@pytest.mark.skip
@pytest.mark.integration
def test_do_insert_sibling(self, test_attributes, test_tablemodel):
"""should add a record to the record tree and update last_id."""
pub.subscribe(self.on_succeed_insert_sibling, "succeed_insert_design_electric")

assert test_tablemodel.tree.get_node(8) is None
assert test_tablemodel.tree.get_node(9) is None

test_attributes["hardware_id"] = 8
test_attributes["hardware_id"] = 9
test_attributes["parent_id"] = 1
test_attributes["record_id"] = 8
test_attributes["record_id"] = 9
pub.sendMessage("request_insert_design_electric", attributes=test_attributes)

assert isinstance(
test_tablemodel.tree.get_node(8).data["design_electric"],
RAMSTKDesignElectricRecord,
)
# assert isinstance(
# test_tablemodel.tree.get_node(9).data["design_electric"],
# RAMSTKDesignElectricRecord,
# )

pub.unsubscribe(
self.on_succeed_insert_sibling, "succeed_insert_design_electric"
Expand All @@ -112,14 +113,14 @@ def test_do_insert_no_hardware(self, test_attributes, test_tablemodel):
"""should not add a record when passed a non-existent hardware ID."""
pub.subscribe(self.on_fail_insert_no_hardware, "fail_insert_design_electric")

assert test_tablemodel.tree.get_node(9) is None
assert test_tablemodel.tree.get_node(10) is None

test_attributes["hardware_id"] = 9
test_attributes["hardware_id"] = 10
test_attributes["parent_id"] = 1
test_attributes["record_id"] = 8
test_attributes["record_id"] = 10
pub.sendMessage("request_insert_design_electric", attributes=test_attributes)

assert test_tablemodel.tree.get_node(9) is None
assert test_tablemodel.tree.get_node(10) is None

pub.unsubscribe(self.on_fail_insert_no_hardware, "fail_insert_design_electric")

Expand Down Expand Up @@ -158,7 +159,7 @@ def test_do_delete(self, test_tablemodel):
_last_id = test_tablemodel.last_id
pub.sendMessage("request_delete_design_electric", node_id=_last_id)

assert test_tablemodel.last_id == 6
assert test_tablemodel.last_id == 7
assert test_tablemodel.tree.get_node(_last_id) is None

pub.unsubscribe(self.on_succeed_delete, "succeed_delete_design_electric")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class TestInsertMethods:
def on_succeed_insert_sibling(self, tree):
assert isinstance(tree, Tree)
assert isinstance(
tree.get_node(8).data["design_mechanic"], RAMSTKDesignMechanicRecord
tree.get_node(9).data["design_mechanic"], RAMSTKDesignMechanicRecord
)
assert tree.get_node(8).data["design_mechanic"].hardware_id == 8
assert tree.get_node(9).data["design_mechanic"].hardware_id == 9
print("\033[36m\nsucceed_insert_design_mechanic topic was broadcast.")

def on_fail_insert_no_hardware(self, error_message):
Expand All @@ -86,20 +86,21 @@ def on_fail_insert_no_hardware(self, error_message):
"\033[35m\nfail_insert_design_mechanic topic was broadcast on no hardware."
)

@pytest.mark.skip
@pytest.mark.integration
def test_do_insert_sibling(self, test_attributes, test_tablemodel):
"""should add a record to the record tree and update last_id."""
pub.subscribe(self.on_succeed_insert_sibling, "succeed_insert_design_mechanic")

assert test_tablemodel.tree.get_node(8) is None
assert test_tablemodel.tree.get_node(9) is None

test_attributes["hardware_id"] = 8
test_attributes["hardware_id"] = 9
test_attributes["parent_id"] = 1
test_attributes["record_id"] = 8
test_attributes["record_id"] = 9
pub.sendMessage("request_insert_design_mechanic", attributes=test_attributes)

assert isinstance(
test_tablemodel.tree.get_node(8).data["design_mechanic"],
test_tablemodel.tree.get_node(9).data["design_mechanic"],
RAMSTKDesignMechanicRecord,
)

Expand All @@ -112,11 +113,11 @@ def test_do_insert_no_hardware(self, test_attributes, test_tablemodel):
"""should not add a record when passed a non-existent hardware ID."""
pub.subscribe(self.on_fail_insert_no_hardware, "fail_insert_design_mechanic")

assert test_tablemodel.tree.get_node(9) is None
assert test_tablemodel.tree.get_node(10) is None

test_attributes["hardware_id"] = 9
test_attributes["hardware_id"] = 10
test_attributes["parent_id"] = 1
test_attributes["record_id"] = 9
test_attributes["record_id"] = 10
pub.sendMessage("request_insert_design_mechanic", attributes=test_attributes)

assert test_tablemodel.tree.get_node(9) is None
Expand Down Expand Up @@ -158,7 +159,7 @@ def test_do_delete(self, test_tablemodel):
_last_id = test_tablemodel.last_id
pub.sendMessage("request_delete_design_mechanic", node_id=_last_id)

assert test_tablemodel.last_id == 6
assert test_tablemodel.last_id == 7
assert test_tablemodel.tree.get_node(_last_id) is None

pub.unsubscribe(self.on_succeed_delete, "succeed_delete_design_mechanic")
Expand Down
Loading

0 comments on commit f1e18e2

Please sign in to comment.