Ejemplo n.º 1
0
 def test_agent_settings(self):
     '''
     Test - Manage the SNMP sysContact, sysLocation, and sysServices settings.
     '''
     kwargs = {
         'name': 'agent-settings',
         'contact': 'TestContact',
         'location': 'TestLocation',
         'services': ['Internet']
     }
     ret = {
         'name': kwargs['name'],
         'changes': {},
         'comment': 'Agent settings already contain the provided values.',
         'result': True
     }
     # Using this instead of dictionary comprehension in order to make pylint happy.
     get_ret = dict((key, value) for (key, value) in six.iteritems(kwargs)
                    if key != 'name')
     mock_value_get = MagicMock(return_value=get_ret)
     mock_value_set = MagicMock(return_value=True)
     with patch.dict(
             win_snmp.__salt__, {
                 'win_snmp.get_agent_settings': mock_value_get,
                 'win_snmp.set_agent_settings': mock_value_set
             }):
         with patch.dict(win_snmp.__opts__, {'test': False}):
             self.assertEqual(win_snmp.agent_settings(**kwargs), ret)
Ejemplo n.º 2
0
def test_agent_settings():
    """
    Test - Manage the SNMP sysContact, sysLocation, and sysServices settings.
    """
    kwargs = {
        "name": "agent-settings",
        "contact": "TestContact",
        "location": "TestLocation",
        "services": ["Internet"],
    }
    ret = {
        "name": kwargs["name"],
        "changes": {},
        "comment": "Agent settings already contain the provided values.",
        "result": True,
    }
    # Using this instead of dictionary comprehension in order to make pylint happy.
    get_ret = {key: value for (key, value) in kwargs.items() if key != "name"}
    mock_value_get = MagicMock(return_value=get_ret)
    mock_value_set = MagicMock(return_value=True)
    with patch.dict(
            win_snmp.__salt__,
        {
            "win_snmp.get_agent_settings": mock_value_get,
            "win_snmp.set_agent_settings": mock_value_set,
        },
    ):
        with patch.dict(win_snmp.__opts__, {"test": False}):
            assert win_snmp.agent_settings(**kwargs) == ret