'Test main module args.'

@patch('ansible.modules.network.cloudvision.cv_server_provision.CvpApiError', new_callable=(lambda : MockException))
@patch('ansible.modules.network.cloudvision.cv_server_provision.server_configurable_configlet')
@patch('ansible.modules.network.cloudvision.cv_server_provision.switch_in_compliance')
@patch('ansible.modules.network.cloudvision.cv_server_provision.switch_info')
@patch('ansible.modules.network.cloudvision.cv_server_provision.connect')
@patch('ansible.modules.network.cloudvision.cv_server_provision.AnsibleModule')
def test_main_module_args(self, mock_module, mock_connect, mock_info, mock_comp, mock_server_conf, mock_exception):

    mock_module_object = Mock()
    mock_module_object.params = dict(action='show', switch_name='eos')
    mock_module_object.fail_json.side_effect = SystemExit('Exiting')
    mock_module.return_value = mock_module_object
    mock_connect.return_value = 'Client'
    mock_info.side_effect = mock_exception('Error    Getting    Info')
    argument_spec = dict(host=dict(required=True), port=dict(required=False, default=None), protocol=dict(default='https', choices=['http', 'https']), username=dict(required=True), password=dict(required=True, no_log=True), server_name=dict(required=True), switch_name=dict(required=True), switch_port=dict(required=True), port_vlan=dict(required=False, default=None), template=dict(require=True), action=dict(default='show', choices=['show', 'add', 'remove']), auto_run=dict(type='bool', default=False))
    self.assertRaises(SystemExit, cv_server_provision.main)
    mock_module.assert_called_with(argument_spec=argument_spec, supports_check_mode=False)
    self.assertEqual(mock_connect.call_count, 1)
    self.assertEqual(mock_info.call_count, 1)
    mock_comp.assert_not_called()
    mock_server_conf.assert_not_called()
    mock_module_object.fail_json.assert_called_with(msg='Error    Getting    Info')
