def test_check_with_falsy_condition_yields_one_crit_among_others_ok( disk_pressure_status, params, section ): section.diskpressure.status = disk_pressure_status results = [r for r in kube_node_conditions.check(params, section) if isinstance(r, Result)] assert len([result for result in results if result.state == State.CRIT]) == 1 assert len([result for result in results if result.state == State.OK]) == len(list(section)) - 1
def test_check_ignores_missing_network_unavailable_when_a_condition_does_not_pass( disk_pressure_status, params, section ): section.networkunavailable = None section.diskpressure.status = disk_pressure_status results = [r for r in kube_node_conditions.check(params, section) if isinstance(r, Result)] assert len([result for result in results if result.state == State.CRIT]) == 1 assert len([result for result in results if result.state == State.OK]) == len(list(section)) - 2
def check_result(params, section, custom_section) -> CheckResult: return kube_node_conditions.check(params, section, custom_section)
def test_check_ignores_missing_network_unavailable_when_all_conditions_pass(params, section): section.networkunavailable = None results = [r for r in kube_node_conditions.check(params, section) if isinstance(r, Result)] assert len(results) == 1
def test_check_with_falsy_condition_yields_as_much_results_as_section_items( disk_pressure_status, params, section ): section.diskpressure.status = disk_pressure_status results = list(kube_node_conditions.check(params, section)) assert len(results) == len(list(section))
def test_check_all_results_state_ok(params, section): results = list(kube_node_conditions.check(params, section)) assert isinstance(results[0], Result) assert results[0].state == State.OK
def test_check_yields_single_result_when_all_conditions_pass(params, section): results = list(kube_node_conditions.check(params, section)) assert len(results) == 1
def test_check_with_missing_network_unavailable_all_states_ok(params, section): results = list(kube_node_conditions.check(params, section)) section.networkunavailable = None assert isinstance(results[0], Result) assert results[0].state == State.OK