def test_printing_module_exit_msg_loop_passed(mock_module, mock_loop_route_check):
    """
    cl_prefix_check - test exit_json messages when loop check is true or false
    """
    instance = mock_module.return_value
    values = {"nexthop": "2.2.2.2"}
    instance.params.get.side_effect = mod_args_generator(values)
    # loop check is true, i.e condition is matched
    mock_loop_route_check.return_value = True
    main()
    _msg = "Testing whether route is present. Condition Met"
    instance.exit_json.assert_called_with(msg=_msg, changed=False)
    # loop check is false, i.e condition is not matched
    mock_loop_route_check.return_value = False
    main()
    _msg = "paremeters not found"
    instance.fail_json.assert_called_with(msg=_msg)
def test_printing_module_exit_msg_loop_passed(mock_module,
                                              mock_loop_route_check):
    """
    cl_prefix_check - test exit_json messages when loop check is true or false
    """
    instance = mock_module.return_value
    values = {'nexthop': '2.2.2.2'}
    instance.params.get.side_effect = mod_args_generator(values)
    # loop check is true, i.e condition is matched
    mock_loop_route_check.return_value = True
    main()
    _msg = 'Testing whether route is present. Condition Met'
    instance.exit_json.assert_called_with(msg=_msg, changed=False)
    # loop check is false, i.e condition is not matched
    mock_loop_route_check.return_value = False
    main()
    _msg = 'paremeters not found'
    instance.fail_json.assert_called_with(msg=_msg)
def test_module_args(mock_module, mock_loop_route_check):
    """
    cl_prefix_check - test module arguments
    """
    instance = mock_module.return_value
    values = {"nexthop": "1.1.1.1"}
    instance.params.get.side_effect = mod_args_generator(values)
    main()
    mock_module.assert_called_with(
        argument_spec={
            "prefix": {"required": True, "type": "str"},
            "poll_interval": {"type": "int", "default": 1},
            "timeout": {"type": "int", "default": 2},
            "state": {"type": "str", "default": "present", "choices": ["present", "absent"]},
            "nexthop": {"type": "str", "default": ""},
            "nonexthop": {"type": "str", "default": ""},
        }
    )
def test_module_args(mock_module,
                     mock_loop_route_check):
    """
    cl_prefix_check - test module arguments
    """
    instance = mock_module.return_value
    values = {'nexthop': '1.1.1.1'}
    instance.params.get.side_effect = mod_args_generator(values)
    main()
    mock_module.assert_called_with(
        argument_spec={'prefix': {'required': True, 'type': 'str'},
                       'poll_interval': {'type': 'int', 'default': 1},
                       'timeout': {'type': 'int', 'default': 2},
                       'state': {'type': 'str',
                                 'default': 'present',
                                 'choices': ['present', 'absent']},
                       'nexthop': {'type': 'str', 'default': ''},
                       'nonexthop': {'type': 'str', 'default': ''}
                       })