def test_ensure_cifs_get_called(self):
     ''' fetching details of cifs '''
     set_module_args(self.set_default_args())
     my_obj = my_module()
     my_obj.server = self.server
     cifs_get = my_obj.get_cifs_share()
     print('Info: test_cifs_share_get: %s' % repr(cifs_get))
     assert not bool(cifs_get)
 def test_cifs_modify_called(self, modify_cifs_share):
     ''' modifying cifs'''
     module_args = {}
     module_args.update(self.set_default_args())
     set_module_args(module_args)
     my_obj = my_module()
     if not self.onbox:
         my_obj.server = MockONTAPConnection('cifs')
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_cifs_apply: %s' % repr(exc.value))
     modify_cifs_share.assert_called_with()
 def test_if_all_methods_catch_exception(self):
     module_args = {}
     module_args.update(self.set_default_args())
     set_module_args(module_args)
     my_obj = my_module()
     if not self.onbox:
         my_obj.server = MockONTAPConnection('cifs_fail')
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.create_cifs_share()
     assert 'Error creating cifs-share' in exc.value.args[0]['msg']
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.delete_cifs_share()
     assert 'Error deleting cifs-share' in exc.value.args[0]['msg']
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.modify_cifs_share()
     assert 'Error modifying cifs-share' in exc.value.args[0]['msg']
 def test_ensure_apply_for_cifs_called(self):
     ''' creating cifs share and checking idempotency '''
     module_args = {}
     module_args.update(self.set_default_args())
     set_module_args(module_args)
     my_obj = my_module()
     if not self.onbox:
         my_obj.server = self.server
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_cifs_apply: %s' % repr(exc.value))
     assert exc.value.args[0]['changed']
     if not self.onbox:
         my_obj.server = MockONTAPConnection('cifs')
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_cifs_apply: %s' % repr(exc.value))
     assert exc.value.args[0]['changed']
 def test_module_fail_when_required_args_missing(self):
     ''' required arguments are reported as errors '''
     with pytest.raises(AnsibleFailJson) as exc:
         set_module_args({})
         my_module()
     print('Info: %s' % exc.value.args[0]['msg'])