Esempio n. 1
0
def test_calculate_mil_hdbk_217f_part_count_missing_quality():
    """calculate_mil_hdbk_217f_part_count() should return an error message when the quality ID is missing."""
    ATTRIBUTES['environment_active_id'] = 1
    ATTRIBUTES['quality_id'] = 4
    ATTRIBUTES['type_id'] = 1

    _attributes, _msg = Filter.calculate_217f_part_count(**ATTRIBUTES)

    assert isinstance(_attributes, dict)
    assert _msg == ('RAMSTK WARNING: piQ is 0.0 when calculating filter, '
                    'hardware ID: 6, quality ID: 4')
    assert _attributes['lambda_b'] == 0.022
    assert _attributes['piQ'] == 0.0
    assert _attributes['hazard_rate_active'] == 0.0
Esempio n. 2
0
def test_calculate_mil_hdbk_217f_part_count_missing_environment():
    """calculate_mil_hdbk_217f_part_count() should return an error message when the active environment ID is missing."""
    ATTRIBUTES['environment_active_id'] = 100
    ATTRIBUTES['quality_id'] = 1
    ATTRIBUTES['type_id'] = 1

    _attributes, _msg = Filter.calculate_217f_part_count(**ATTRIBUTES)

    assert isinstance(_attributes, dict)
    assert _msg == ('RAMSTK WARNING: Base hazard rate is 0.0 when calculating '
                    'filter, hardware ID: 6, type ID: 1, active environment '
                    'ID: 100')
    assert _attributes['lambda_b'] == 0.0
    assert _attributes['piQ'] == 1.0
    assert _attributes['hazard_rate_active'] == 0.0
Esempio n. 3
0
def test_calculate_mil_hdbk_217f_part_stress():
    """calculate_mil_hdbk_217f_part_stress() should return a dictionary of updated values on success."""
    ATTRIBUTES['hazard_rate_method_id'] = 2
    ATTRIBUTES['environment_active_id'] = 4
    ATTRIBUTES['quality_id'] = 1
    ATTRIBUTES['type_id'] = 2

    _attributes, _msg = Filter.calculate_217f_part_stress(**ATTRIBUTES)

    assert isinstance(_attributes, dict)
    assert _msg == ''
    assert pytest.approx(_attributes['lambda_b'], 0.12)
    assert _attributes['piQ'] == 1.0
    assert _attributes['piE'] == 4.0
    assert pytest.approx(_attributes['hazard_rate_active'], 0.48)
Esempio n. 4
0
def test_calculate_mil_hdbk_217f_part_stress_missing_environment():
    """calculate_mil_hdbk_217f_part_stress() should return a zero active hazard rate and non-empty message when the environment ID is not an index in the list."""
    ATTRIBUTES['hazard_rate_method_id'] = 2
    ATTRIBUTES['environment_active_id'] = 40
    ATTRIBUTES['quality_id'] = 1
    ATTRIBUTES['type_id'] = 2

    _attributes, _msg = Filter.calculate_217f_part_stress(**ATTRIBUTES)

    assert isinstance(_attributes, dict)
    assert _msg == 'RAMSTK WARNING: piE is 0.0 when ' \
                   'calculating filter, hardware ID: 6'
    assert pytest.approx(_attributes['lambda_b'], 0.012)
    assert _attributes['piQ'] == 1.0
    assert _attributes['piE'] == 0.0
    assert pytest.approx(_attributes['hazard_rate_active'], 0.0)
Esempio n. 5
0
def test_calculate_mil_hdbk_217f_part_count(type_id, quality_id,
                                            environment_active_id):
    """calculate_mil_hdbk_217f_part_count() should return a dictionary of updated values on success."""
    ATTRIBUTES['hazard_rate_method_id'] = 1
    ATTRIBUTES['type_id'] = type_id
    ATTRIBUTES['quality_id'] = quality_id
    ATTRIBUTES['environment_active_id'] = environment_active_id

    lambda_b = PART_COUNT_LAMBDA_B[type_id][environment_active_id - 1]
    piQ = PART_COUNT_PIQ[quality_id - 1]

    _attributes, _msg = Filter.calculate_217f_part_count(**ATTRIBUTES)

    assert isinstance(_attributes, dict)
    if lambda_b == 0.0:
        assert _msg == ('RAMSTK WARNING: Base hazard rate is 0.0 when '
                        'calculating filter, hardware ID: 6')
    else:
        assert _msg == ''
    assert _attributes['lambda_b'] == lambda_b
    assert _attributes['piQ'] == piQ
    assert _attributes['hazard_rate_active'] == lambda_b * piQ