def test_replace_config_ifquery_not_outputting_text(mock_run_cmd, mock_module): mock_module.params = {'location': './tests/', 'name': 'swp1'} mock_module.custom_desired_config = { 'name': 'swp1', 'addr_method': None, 'config': { 'address': '10.1.1.2/24', 'mtu': '9000' } } mock_run_cmd.return_value = 'ifupdown did something' mock_module.jsonify = MagicMock( return_value=json.dumps([mock_module.custom_desired_config])) cl_int.replace_config(mock_module) assert_equals(mock_module.fail_json.call_count, 0)
def test_replace_config_ifquery_not_outputting_text(mock_run_cmd, mock_module): mock_module.params = {'location': './tests/', 'name': 'swp1' } mock_module.custom_desired_config = { 'name': 'swp1', 'addr_method': None, 'config': {'address': '10.1.1.2/24', 'mtu': '9000'} } mock_run_cmd.return_value = 'ifupdown did something' mock_module.jsonify = MagicMock( return_value=json.dumps([mock_module.custom_desired_config])) cl_int.replace_config(mock_module) assert_equals(mock_module.fail_json.call_count, 0)
def test_replace_config_ifquery_not_outputting_text(mock_run_cmd, mock_module): mock_module.params = {'location': './tests/', 'name': 'swp1'} mock_module.custom_desired_config = { 'name': 'swp1', 'addr_method': None, 'config': { 'address': '10.1.1.2/24', 'mtu': '9000' } } mock_run_cmd.return_value = '' mock_module.jsonify = MagicMock( return_value=json.dumps([mock_module.custom_desired_config])) cl_int.replace_config(mock_module) _msg = 'desired_config not copied into ifupdown2 text format. Not writing config to file' mock_module.fail_json.assert_called_with(msg=_msg)
def test_replace_config_ifquery_not_outputting_text(mock_run_cmd, mock_module): mock_module.params = {'location': './tests/', 'name': 'swp1' } mock_module.custom_desired_config = { 'name': 'swp1', 'addr_method': None, 'config': {'address': '10.1.1.2/24', 'mtu': '9000'} } mock_run_cmd.return_value = '' mock_module.jsonify = MagicMock( return_value=json.dumps([mock_module.custom_desired_config])) cl_int.replace_config(mock_module) _msg='desired_config not copied into ifupdown2 text format. Not writing config to file' mock_module.fail_json.assert_called_with(msg=_msg)