コード例 #1
0
def test_module_args(mock_module,
                     mock_curr_config,
                     mock_desired_config,
                     mock_compare,
                     mock_replace,
                     mock_exists):
    """ cl_interface - test module args """
    mock_exists.return_value = True
    cl_int.main()
    mock_module.assert_called_with(
        required_together=[['virtual_ip', 'virtual_mac'],
                           ['clagd_enable', 'clagd_priority',
                            'clagd_peer_ip', 'clagd_sys_mac'],
                           ['clagd_enable', 'clagd_backup_ip']],
        argument_spec={
            'addr_method': {
                'type': 'str',
                'choices': ['', 'loopback', 'dhcp']},
            'name': {'required': True, 'type': 'str'},
            'mtu': {'type': 'str'},
            'alias_name': {'type': 'str'},
            'ipv4': {'type': 'list'},
            'ipv6': {'type': 'list'},
            'virtual_mac': {'type': 'str'},
            'virtual_ip': {'type': 'str'},
            'vids': {'type': 'list'},
            'pvid': {'type': 'str'},
            'bridge_access': {'type': 'str'},
            'mstpctl_portnetwork': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'mstpctl_portadminedge': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'mstpctl_bpduguard': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'clagd_enable': {'type': 'bool', 'choices': [
                'yes', 'on', '1', 'true', 1, 'no', 'off', '0', 'false', 0]},
            'clagd_peer_ip': {'type': 'str'},
            'clagd_sys_mac': {'type': 'str'},
            'clagd_priority': {'type': 'str'},
            'clagd_args': {'type': 'str'},
            'clagd_backup_ip': {'type': 'str'},
            'location': {'type': 'str',
                         'default': '/etc/network/interfaces.d'},
            'speed': {'type': 'str'}}
    )
コード例 #2
0
def test_module_args(mock_module, mock_curr_config, mock_desired_config, mock_compare, mock_replace, mock_exists):
    """ cl_interface - test module args """
    mock_exists.return_value = True
    cl_int.main()
    mock_module.assert_called_with(
        required_together=[
            ["virtual_ip", "virtual_mac"],
            ["clagd_enable", "clagd_priority", "clagd_peer_ip", "clagd_sys_mac"],
            ["clagd_enable", "clagd_backup_ip"],
        ],
        argument_spec={
            "addr_method": {"type": "str", "choices": ["", "loopback", "dhcp"]},
            "name": {"required": True, "type": "str"},
            "mtu": {"type": "str"},
            "alias_name": {"type": "str"},
            "ipv4": {"type": "list"},
            "ipv6": {"type": "list"},
            "virtual_mac": {"type": "str"},
            "virtual_ip": {"type": "str"},
            "vids": {"type": "list"},
            "pvid": {"type": "str"},
            "bridge_access": {"type": "str"},
            "mstpctl_portnetwork": {
                "type": "bool",
                "choices": ["yes", "on", "1", "true", 1, "no", "off", "0", "false", 0],
            },
            "mstpctl_portadminedge": {
                "type": "bool",
                "choices": ["yes", "on", "1", "true", 1, "no", "off", "0", "false", 0],
            },
            "mstpctl_bpduguard": {
                "type": "bool",
                "choices": ["yes", "on", "1", "true", 1, "no", "off", "0", "false", 0],
            },
            "clagd_enable": {"type": "bool", "choices": ["yes", "on", "1", "true", 1, "no", "off", "0", "false", 0]},
            "clagd_peer_ip": {"type": "str"},
            "clagd_sys_mac": {"type": "str"},
            "clagd_priority": {"type": "str"},
            "clagd_args": {"type": "str"},
            "clagd_backup_ip": {"type": "str"},
            "location": {"type": "str", "default": "/etc/network/interfaces.d"},
            "speed": {"type": "str"},
        },
    )
コード例 #3
0
def test_main_integration_test(mock_module,
                               mock_curr_config,
                               mock_desired_config,
                               mock_compare,
                               mock_replace, mock_exists):
    """ cl_interface - basic integration test of main """
    mock_exists.return_value = True
    instance = mock_module.return_value
    # if config_changed == false. no change
    instance.params = {'name': 'swp1'}
    mock_compare.return_value = False
    cl_int.main()
    instance.exit_json.assert_called_with(
        msg='interface swp1 config not changed',
        changed=False)
    # if config_changed == true, change
    mock_compare.return_value = True
    cl_int.main()
    instance.exit_json.assert_called_with(
        msg='interface swp1 config updated',
        changed=True)
    # if location does not exist
    instance.params['location'] = '/etc/network/ansible'
    mock_exists.return_value = False
    cl_int.main()
    instance.fail_json.assert_called_with(msg='/etc/network/ansible does not exist.')