def test_firewall_multicast_policy_deletion_fails(mocker): schema_method_mock = mocker.patch('ansible_collections.notmintest.not_a_real_collection.plugins.module_utils.network.fortios.fortios.FortiOSHandler.schema') delete_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500} delete_method_mock = mocker.patch('ansible_collections.notmintest.not_a_real_collection.plugins.module_utils.network.fortios.fortios.FortiOSHandler.delete', return_value=delete_method_result) input_data = { 'username': '******', 'state': 'absent', 'firewall_multicast_policy': { 'action': 'accept', 'dnat': 'test_value_4', 'dstintf': 'test_value_5', 'end_port': '6', 'id': '7', 'logtraffic': 'enable', 'protocol': '9', 'snat': 'enable', 'snat_ip': 'test_value_11', 'srcintf': 'test_value_12', 'start_port': '13', 'status': 'enable' }, 'vdom': 'root'} is_error, changed, response = fortios_firewall_multicast_policy.fortios_firewall(input_data, fos_instance) delete_method_mock.assert_called_with('firewall', 'multicast-policy', mkey=ANY, vdom='root') schema_method_mock.assert_not_called() assert is_error assert not changed assert response['status'] == 'error' assert response['http_status'] == 500
def test_firewall_multicast_policy_filter_foreign_attributes(mocker): schema_method_mock = mocker.patch('ansible_collections.notmintest.not_a_real_collection.plugins.module_utils.network.fortios.fortios.FortiOSHandler.schema') set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200} set_method_mock = mocker.patch('ansible_collections.notmintest.not_a_real_collection.plugins.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result) input_data = { 'username': '******', 'state': 'present', 'firewall_multicast_policy': { 'random_attribute_not_valid': 'tag', 'action': 'accept', 'dnat': 'test_value_4', 'dstintf': 'test_value_5', 'end_port': '6', 'id': '7', 'logtraffic': 'enable', 'protocol': '9', 'snat': 'enable', 'snat_ip': 'test_value_11', 'srcintf': 'test_value_12', 'start_port': '13', 'status': 'enable' }, 'vdom': 'root'} is_error, changed, response = fortios_firewall_multicast_policy.fortios_firewall(input_data, fos_instance) expected_data = { 'action': 'accept', 'dnat': 'test_value_4', 'dstintf': 'test_value_5', 'end-port': '6', 'id': '7', 'logtraffic': 'enable', 'protocol': '9', 'snat': 'enable', 'snat-ip': 'test_value_11', 'srcintf': 'test_value_12', 'start-port': '13', 'status': 'enable' } set_method_mock.assert_called_with('firewall', 'multicast-policy', data=expected_data, vdom='root') schema_method_mock.assert_not_called() assert not is_error assert changed assert response['status'] == 'success' assert response['http_status'] == 200