Tests Documentation

  • all tests can be evaluated via pytest

  • executing pytest from the tests directory or above within the repo will execute all tests

  • executing pytest within a specific directory will only execute tests in that directory

  • executing pytest path/to/text_file.py will only execute single specified test

Unit Tests

test_api docu

class helpr.tests.unit_tests.test_api.APITestCase(methodName='runTest')

Class for unit tests of api module

assert_is_file(path)

function to assert if file exists

rm_tree(path)

function to remove results save folder after unit test

setUp()

function to specify common inputs to api module

tearDown()

teardown function

test_api_bounding_sensitivity_study()

unit test for specifying a bound value sensitivity study in api

test_api_lhs_sensitivity_study()

unit test for specifying a bound value sensitivity study in api

test_api_nominal_evaluations()

unit test for ensuring nominal probabilistic results match deterministic results

test_api_scalar_inputs()

unit test for passing scaling inputs (deterministic evaluation) to api

test_api_uncertain_inputs()

unit test for passing uncertain inputs to api

test_bad_study_type_specification()

unit test for specifying a bound value sensitivity study in api

test_create_failure_assessment_diagram()

unit test for creating failure assessment diagram

test_create_input_parameter_plots()

unit test for creating input parameter plots

test_create_probabilistic_plots()

unit test for creating probabilistic plots

test_generating_intermediate_variables()

unit test for generating intermediate variables (derived from input variables)

test_incorrect_parameter_name()

unit test for warning of incorrect parameter name

test_inspection_mitigation_results()

unit test for applying inspection mitigation function to crack evolution results

test_print_intermediate_variables()

unit test for printing nominal intermediate variables

test_reload_random_seed()

unit test to check ability to use previous random seed

test_save_deterministic_results()

unit test to check deterministic result saving capability

test_save_probabilistic_results()

unit test to check probabilistic result saving capability

test_specifying_random_seed()

unit test to check ability to specify random seed

test_crack_growth docu

class helpr.tests.unit_tests.test_crack_growth.CrackGrowthTestCase(methodName='runTest')

Class for units tests of crack growth module

setUp()

function to specify common inputs to crack growth module

tearDown()

teardown function

test_0pct_h2()

unit test for having no hydrogen in crack growth calculations

test_100pct_h2()

unit test that crack growth following ASME curve

test_bad_crack_growth_model_specifications()

unit test for passing invalid crack growth rate model

test_default()

unit test of default behavior of crack growth module

test_design_curve_function()

unit test to check that design curve calculation function performs as expected

test_input_types()

unit test for passing lists of inputs to crack growth module

test_invalid_fugacity_correction_case()

unit test of passing invalid input to fugacity correction

test_specify_paris_law_crack_growth()

unit test of specifying inputs for a paris law crack growth model

test_crack_initiation docu

class helpr.tests.unit_tests.test_crack_initiation.CrackInitiationTestCase(methodName='runTest')

Class for units test of crack initiation module

setUp()

function for specifying common inputs to crack initiation module

tearDown()

teardown function

test_array_inputs()

unit test of passing input arrays to crack initiation module

test_bad_surface_specification()

unit test of check that bad specifications of defect surface are caught

test_default()

unit test of default functionality of crack initiation module

test_cycle_evolution docu

class helpr.tests.unit_tests.test_cycle_evolution.CycleEvolutionTestCase(methodName='runTest')

class for unit tests of cycle evolution module

setUp()

function to specify common cycle evolution inputs

tearDown()

teardown function

test_array_input()

test array input for cycle evolution class

test_bad_delta_c_rule_specification()

test to check that improper delta_c_rule specifications fail

test_bad_delta_c_rule_specification_list()

test to check that improper delta_c_rule specifications fail with list inputs

test_calc_life_assessment_w_cycle_step()

test to confirm the life assessment behaves properly when a cycle step is provided

test_calc_life_assessment_w_max()

test to confirm the life assessment behaves properly when a max number of cycles is provided

test_calc_life_assessment_w_max_overridden()

test to confirm the life assessment behaves properly when a max number of cycles is provided but a/t > 0.8 is reached before that number of cycles

test_default()

test default functionality of cycle evolution class

test_fixed_c()

test to check crack length remains unchanged when specified even if the cycling still works properly

test_independent_c()

test to check crack length independently propagates when specified

test_independent_c_list()

test to check crack length independently propagates when specified with list inputs

test_proportional_c()

test to check crack length ratio to a remains unchanged when specified even if the cycling still works properly

test_proportional_c_list()

test to check crack length ratio to a remains unchanged when specified even if the cycling still works properly with list inputs

test_environment docu

class helpr.tests.unit_tests.test_environment.EnvironmentTestCase(methodName='runTest')

Class for unit tests of environment module

setUp()

function to specify common inputs to environment module

tearDown()

teardown function

test_array_input()

unit test of passing array of pressure values to environment module

test_fugacity_ratio()

unit test of fugacity ratio calculation

test_h2_volume_fraction()

unit test of changing h2 mvolume fraction in environment

test_r_ratio()

unit test of r ratio calculation

test_fracture docu

class helpr.tests.unit_tests.test_fracture.FractureTestCase(methodName='runTest')

class for fracture module unit tests

setUp()

function for specifying common fracture module inputs

tearDown()

teardown function

test_assessment_primaryOnly()

unit test of failure assessment with only primary stress.

test_assessment_withSecondary()

unit test of failure assessment with primary and secondary/residual stress.

test_inspection_mitigation docu

class helpr.tests.unit_tests.test_inspection_mitigation.InspectionMitigationTestCase(methodName='runTest')

unit tests for inspection and mitigation module

setUp()

function for specifying common inspection mitigation module inputs

tearDown()

” teardown function

test_crack_inspection()

unit test for crack inspection function

test_crack_mitigation()

unit test for crack mitigation function

test_determine_inspection_schedule()

test of determining inspection schedule function

test_inspection_indices()

test of inspection indices function

test_material docu

class helpr.tests.unit_tests.test_material.MaterialTestCase(methodName='runTest')

class for unit tests of material module

setUp()

function for specifying common material module inputs

tearDown()

teardown function

test_default()

unit test of default behavior for material module

test_single_instance()

unit test of accessing single instance of material specification object

test_parameter docu

class helpr.tests.unit_tests.test_parameter.ParameterTestCase(methodName='runTest')

class for unit test of parameter module

setUp() None

Hook method for setting up the test fixture before exercising it.

tearDown() None

teardown function

test_above_bounds()

unit test of specifying parameter value above upper bound

test_bad_size_specification()

unit test to check that bad size specification does not work

test_below_bounds()

unit test of specifying parameter value below lower bound

test_default()

unit tests of default behavior of parameter module

test_list_above_bounds()

unit test of passing list of inputs with one value above parameter upper bounds

test_list_below_bounds()

unit test of passing list of inputs with one value below parameter lower bounds

test_make_array()

unit test of specifying size of parameter object

test_passed_list()

unit test of passing list of parameter values to parameter module

test_pipe docu

class helpr.tests.unit_tests.test_pipe.PipeTestCase(methodName='runTest')

class for pipe module unit tests

setUp()

function to specify common inputs to pipe module

tearDown()

teardown function

test_array_input()

unit test of passing array of inputs to pipe module

test_bad_pipe_size()

unit tests of bad pipe size specification

test_simple_calcs()

unit test to check simple pipe calculations

test_plots docu

class helpr.tests.unit_tests.test_plots.PlotsTestCase(methodName='runTest')

class for plotting functions

setUp()

function to specify common inputs to plot functions

tearDown()

Hook method for deconstructing the test fixture after testing it.

test_crack_growth_rate_plot()

test for creation of crack growth rate plot

test_cycle_life_cdf_ci()

test for creation of life criteria cdf confidence intervals plot

test_cycle_life_cdfs()

test for creation of life criteria cdfs plot

test_cycle_life_criteria_scatter_plot_color_by_variable()

test for creation of life criteria scatter plot with changing colors by variable

test_cycle_life_criteria_scatter_plot_no_color_by_variable()

test for creation of life criteria scatter plot without changing colors by variable

test_cycle_life_pdf()

test for creation of life criteria pdfs plot

test_design_curve_plot()

test for creation of design curve plot

test_failure_assessment_diagram_anderson()

test for creation of failure assessment diagram using the Anderson stress intensity method.

test_failure_assessment_diagram_api()

test for creation of failure assessment diagram using the API stress intensity method.

test_inspection_mitigation_plots()

test for creation of inspection mitigation plots

test_life_assessment_ensemble_plot()

test for creation of life assessment plot for pipe ensemble

test_pipe_life_assessment_plot()

test for creation of lfe assessment plot for single instance

test_sensitivity_results_plot()

test for creation of sensitivity plot

class helpr.tests.unit_tests.test_plots.PlotsTestCaseBase(methodName='runTest')

base class plotting unit test that check if file exists

assert_is_file(path)

function to check if a file exists

test_postprocessing docu

class helpr.tests.unit_tests.test_postprocessing.PostProcessingTestCase(methodName='runTest')

unit test for postprocessing module

setUp()

function to specify common postprocessing inputs

tearDown()

tear down function

test_calc_pipe_life_criteria_default_a_crit()

test that a(crit)/t defaults to 0.8 if the pipe fracture resistance is never met.

test_calc_pipe_life_criteria_hydrogen_impact()

test that a(crit) and associated number of cycles match expected values from internal development notebook varying amount of hydrogen

test_calc_pipe_life_criteria_typical()

test that a(crit) and associated number of cycles match expected values from the examples/demo_deterministic.ipynb notebook

test_crack_evolution_plotting()

” test for generating crack evolution plot

test_stress_state docu

class helpr.tests.unit_tests.test_stress_state.InternalAxialHoopStressTestCase(methodName='runTest')

class for unit tests of internal axial hoop stress class

setUp()

Hook method for setting up the test fixture before exercising it.

test_axial_hoop_stress_check()

unit test of check of axial hoop stress exceeding yield strength

test_axial_hoop_stress_state_specification()

unit test of internal axial hoop stress state specification

test_calc_G_parameters_finite_length_full_depth()

unit test to check that interpolation of Table 9B12 produces expected G values (hand calc) for single of crack at full depth

test_calc_G_parameters_finite_length_other_point()

unit test to check that interpolation of Table 9B12 produces expected G values (hand calc) for single of crack at specified point

test_calc_G_parameters_finite_length_surface()

unit test to check that interpolation of Table 9B12 produces expected G values (hand calc) for single of crack at surface

test_check_anderson_solution_assumptions_a_over_t_violation()

unit test for function checking for catching violations of a/t <= 0.8 assumption in Anderson method

test_check_anderson_solution_assumptions_r_i_over_t_violation()

unit test for function checking for catching violation of 5 <= R_i/t <= 20 assumption in Anderson method

test_check_api_solution_assumptions_a_over_t_violation()

unit test for function checking for catching violations of a/t <= 0.8 assumption in API 579-1 method

test_get_single_stress_state()

unit test of single stress state function

test_interp_table_parameters_Table_9B10_matrix_inputs()

unit test to check that interpolation of Table 9B10 produces expected G values (hand calc) for vector of internal cracks

test_interp_table_parameters_Table_9B10_single_inputs_external()

unit test to check that interpolation of Table 9B10 produces expected G values (hand calc) for single external crack

test_interp_table_parameters_Table_9B10_single_inputs_internal()

unit test to check that interpolation of Table 9B10 produces expected values (hand calc) for single internal crack

test_interp_table_parameters_Table_9B12_matrix_inputs()

unit test to check that interpolation of Table 9B12 produces expected A values (hand calc) for vector of cracks

test_interp_table_parameters_Table_9B12_single_inputs()

unit test to check that interpolation of Table 9B12 produces expected A values (hand calc) for single crack

test_interp_table_parameters_Table_9B13_matrix_inputs()

unit test to check that interpolation of Table 9B13 produces expected A values (hand calc) for vector of cracks

test_interp_table_parameters_Table_9B13_single_inputs()

unit test to check that interpolation of Table 9B13 produces expected A values (hand calc) for single crack

test_interp_table_parameters_vector_lengths_not_matching()

unit test to check that API table interpolation raises an error if input arguments are not 1 or all the same

test_ref_stress_api()

unit test to check default behavior of API reference stress solution method for typical inputs.

test_stress_intensity_factor_anderson_external()

unit test to check that axial hoop stress intensity factor calculated with Anderson’s equation produces error message for external crack

test_stress_intensity_factor_anderson_internal()

unit test to check that axial hoop stress intensity factor calculated with Anderson’s equation produces expected values (hand calc) for internal crack

test_stress_intensity_factor_api_external()

unit test to check that axial hoop stress intensity factor calculated with API method produces expected value (hand calc) for external crack

test_stress_intensity_factor_api_internal()

unit test to check that axial hoop stress intensity factor calculated with API method produces expected value (hand calc) for internal crack

test_stress_intensity_factor_invalid_method()

unit test to check an exception is raised when a method other than Anderson or API is raised

class helpr.tests.unit_tests.test_stress_state.StressStateTestCase(methodName='runTest')

class for unit tests of stress state module

setUp()

Hook method for setting up the test fixture before exercising it.

test_circumferential_longitudinal_stress_check()

unit test of check of axial longitudinal stress exceeding yield strength

test_circumferential_longitudinal_stress_intensity_factor()

unit test of check of axial longitudinal stress exceeding yield strength

test_circumferential_longitudinal_stress_state_specification()

unit test of longitudinal stress states specification

test_generic_stress_state_specification()

unit test of generic stress state state specification

Verification Tests

test_verification_crack_growth_rate docu

class helpr.tests.verification_tests.test_verification_crack_growth_rate.VerificationCrackGrowth(methodName='runTest')

Class for verification tests of crack growth rate calculations

calculate_crack_evolution_error(truth, simulation_data)

function for calculating % rel. err. between predictions and data

calculate_error_metrics(truth, simulation_data)

function for calculating error metrics

setUp()

Hook method for setting up the test fixture before exercising it.

tearDown()

teardown function

test_dataset_1()

“verification test using dataset 1

test_dataset_2()

verification test using dataset 2

test_dataset_3()

verification test using dataset 3

verification_raw_comparison_plot(verification_data, simulation_data, condition)

function for creating verification comparison plots