def test_interface(self): config = [{'interfaces': {'enp14s0u1u2': {'promiscuity': None}}}] LAST_STATS = network_settings._copy_interfaces_info({'enp14s0u1u2': {'family': '0', 'promiscuity': '0', 'group': '0'}}) NEW_STATS = network_settings._copy_interfaces_info({'enp14s0u1u2': {'family': '0', 'promiscuity': '1', 'group': '0'}}) ret = network_settings.validate(config) self.assertEqual(ret, (True, 'Valid beacon configuration')) with patch.object(network_settings, 'LAST_STATS', {}), \ patch.object(network_settings, 'IP', MockIPClass), \ patch('salt.beacons.network_settings._copy_interfaces_info', MagicMock(side_effect=[LAST_STATS, NEW_STATS])): ret = network_settings.beacon(config) self.assertEqual(ret, []) ret = network_settings.beacon(config) _expected = [{'interface': 'enp14s0u1u2', 'tag': 'enp14s0u1u2', 'change': {'promiscuity': '1'} }] self.assertEqual(ret, _expected)
def test_interface(self): config = [{"interfaces": {"enp14s0u1u2": {"promiscuity": None}}}] LAST_STATS = network_settings._copy_interfaces_info( {"enp14s0u1u2": { "family": "0", "promiscuity": "0", "group": "0" }}) NEW_STATS = network_settings._copy_interfaces_info( {"enp14s0u1u2": { "family": "0", "promiscuity": "1", "group": "0" }}) ret = network_settings.validate(config) self.assertEqual(ret, (True, "Valid beacon configuration")) with patch.object(network_settings, "LAST_STATS", {}), patch.object( network_settings, "IP", MockIPClass), patch( "salt.beacons.network_settings._copy_interfaces_info", MagicMock(side_effect=[LAST_STATS, NEW_STATS]), ): ret = network_settings.beacon(config) self.assertEqual(ret, []) ret = network_settings.beacon(config) _expected = [{ "interface": "enp14s0u1u2", "tag": "enp14s0u1u2", "change": { "promiscuity": "1" }, }] self.assertEqual(ret, _expected)