Exemplo n.º 1
0
def test_data_model_create(test_dao):
    """ __init__() should return a Validation model. """
    DUT = dtmValidation(test_dao)

    assert isinstance(DUT, dtmValidation)
    assert isinstance(DUT.tree, Tree)
    assert isinstance(DUT.dao, DAO)
Exemplo n.º 2
0
def test_do_select_all(test_dao):
    """ do_select_all() should return a Tree() object populated with RAMSTKValidation instances on success. """
    DUT = dtmValidation(test_dao)
    _tree = DUT.do_select_all(revision_id=1)

    assert isinstance(_tree, Tree)
    assert isinstance(_tree.get_node(1).data, RAMSTKValidation)
Exemplo n.º 3
0
def test_do_load_output_validation(test_dao):
    """do_load_output() should return None when loading Validations for export."""
    DUT = dtmExports(test_dao)

    _validation = dtmValidation(test_dao)
    _tree = _validation.do_select_all(revision_id=1)

    assert DUT.do_load_output('Validation', _tree) is None
Exemplo n.º 4
0
def test_do_select(test_dao):
    """ do_select() should return an instance of the RAMSTKValidation data model on success. """
    DUT = dtmValidation(test_dao)
    DUT.do_select_all(revision_id=1)

    _validation = DUT.do_select(1)

    assert isinstance(_validation, RAMSTKValidation)
    assert _validation.validation_id == 1
Exemplo n.º 5
0
def test_do_update_status(test_dao):
    """ do_update_status() should return a zero error code on success. """
    DUT = dtmValidation(test_dao)
    DUT.do_select_all(revision_id=1)

    _error_code, _msg = DUT.do_update_status()

    assert _error_code == 0
    assert _msg == ('RAMSTK SUCCESS: Updating the RAMSTK Program database.')
Exemplo n.º 6
0
def test_do_update_all(test_dao):
    """ do_update_all() should return a zero error code on success. """
    DUT = dtmValidation(test_dao)
    DUT.do_select_all(revision_id=1)

    _error_code, _msg = DUT.do_update_all()

    assert _error_code == 0
    assert _msg == ("RAMSTK SUCCESS: Updating all records in the validation "
                    "table.")
Exemplo n.º 7
0
def test_do_delete_non_existent_id(test_dao):
    """ do_delete() should return a non-zero error code when passed a Validation ID that doesn't exist. """
    DUT = dtmValidation(test_dao)
    DUT.do_select_all(revision_id=1)

    _error_code, _msg = DUT.do_delete(300)

    assert _error_code == 2005
    assert _msg == ('  RAMSTK ERROR: Attempted to delete non-existent '
                    'Validation ID 300.')
Exemplo n.º 8
0
def test_do_delete(test_dao):
    """ do_delete() should return a zero error code on success. """
    DUT = dtmValidation(test_dao)
    DUT.do_select_all(revision_id=1)
    DUT.do_insert(revision_id=1)

    _error_code, _msg = DUT.do_delete(DUT.last_id)

    assert _error_code == 0
    assert _msg == ('RAMSTK SUCCESS: Deleting an item from the RAMSTK Program '
                    'database.')
Exemplo n.º 9
0
def test_do_insert(test_dao):
    """ do_insert() should return False on success. """
    DUT = dtmValidation(test_dao)
    DUT.do_select_all(revision_id=1)

    _error_code, _msg = DUT.do_insert(revision_id=1)

    assert _error_code == 0
    assert _msg == (
        'RAMSTK SUCCESS: Adding one or more items to the RAMSTK Program '
        'database.')
    assert DUT.last_id == 2
Exemplo n.º 10
0
def test_do_update(test_dao):
    """ do_update() should return a zero error code on success. """
    DUT = dtmValidation(test_dao)
    DUT.do_select_all(revision_id=1)

    _validation = DUT.do_select(DUT.last_id)
    _validation.availability_logistics = 0.9832

    _error_code, _msg = DUT.do_update(DUT.last_id)

    assert _error_code == 0
    assert _msg == ('RAMSTK SUCCESS: Updating the RAMSTK Program database.')
Exemplo n.º 11
0
def test_do_calculate_cost(test_dao):
    """ do_calculate() returns False on successfully calculating tasks costs. """
    DUT = dtmValidation(test_dao)
    DUT.do_select_all(revision_id=1)
    _validation = DUT.do_select(1)
    _validation.cost_minimum = 252.00
    _validation.cost_average = 368.00
    _validation.cost_maximum = 441.00
    _validation.confidence = 0.95

    assert not DUT.do_calculate(1, metric='cost')
    assert _validation.cost_mean == pytest.approx(360.83333333)
    assert _validation.cost_variance == pytest.approx(992.25)
Exemplo n.º 12
0
def test_do_calculate_time(test_dao):
    """ do_calculate() returns False on successfully calculating tasks times. """
    DUT = dtmValidation(test_dao)
    DUT.do_select_all(revision_id=1)
    _validation = DUT.do_select(1)
    _validation.time_minimum = 25.2
    _validation.time_average = 36.8
    _validation.time_maximum = 44.1
    _validation.confidence = 0.95

    assert not DUT.do_calculate(1, metric='time')
    assert _validation.time_mean == pytest.approx(36.08333333)
    assert _validation.time_variance == pytest.approx(9.9225)
Exemplo n.º 13
0
def test_do_select_non_existent_id(test_dao):
    """ do_select() should return None when a non-existent Validation ID is requested. """
    DUT = dtmValidation(test_dao)
    _validation = DUT.do_select(100)

    assert _validation is None