def test_route_check_route_found(mock_module, mock_single_run): """ prefix_check - test action when prefix is found """ # on success, single_route_check_run() will return true mock_single_run.return_value = True result = prefix_check.check_if_route_exists(mock_module) assert_equals(result, True)
def test_route_check_route_timeout_occurs(mock_module, mock_single_run, mock_sleep): """ prefix_check - test action when prefix not found. timeout occurs """ # define some important variables for the test. mock_module.timeout = 5 poll_interval = 5 # on failure, single_route_check_run() will return false mock_single_run.return_value = False # Run the function under test result = prefix_check.check_if_route_exists(mock_module) # Confirm that function failed assert_equals(result, False) # Also check that the poll interval works correctly. # Mock time.sleep and check that it was executed # (poll_interface/timeout) times. In this case 5 times. assert_equals(mock_sleep.call_count, poll_interval)