Пример #1
0
 def test_ensure_license_get_called(self):
     ''' fetching details of license '''
     set_module_args(self.set_default_args())
     my_obj = my_module()
     my_obj.server = self.server
     license_get = my_obj.get_licensing_status()
     print('Info: test_license_get: %s' % repr(license_get))
     assert not bool(license_get)
Пример #2
0
 def test_cluster_create_called(self, cluster_create):
     ''' creating cluster'''
     module_args = {}
     module_args.update(self.set_default_args())
     set_module_args(module_args)
     my_obj = my_module()
     my_obj.autosupport_log = Mock(return_value=None)
     if not self.use_vsim:
         my_obj.server = MockONTAPConnection('cluster')
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_cluster_apply: %s' % repr(exc.value))
     cluster_create.assert_called_with()
Пример #3
0
 def test_ensure_apply_for_cluster_called(self):
     ''' creating license and checking idempotency '''
     module_args = {}
     module_args.update(self.set_default_args())
     set_module_args(module_args)
     my_obj = my_module()
     my_obj.autosupport_log = Mock(return_value=None)
     if not self.use_vsim:
         my_obj.server = self.server
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_cluster_apply: %s' % repr(exc.value))
     assert exc.value.args[0]['changed']
     if not self.use_vsim:
         my_obj.server = MockONTAPConnection('cluster')
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_cluster_apply: %s' % repr(exc.value))
     assert exc.value.args[0]['changed']
Пример #4
0
 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.use_vsim:
         my_obj.server = MockONTAPConnection('cluster_fail')
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.get_licensing_status()
     assert 'Error checking license status' in exc.value.args[0]['msg']
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.create_cluster()
     assert 'Error creating cluster' in exc.value.args[0]['msg']
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.cluster_join()
     assert 'Error adding node to cluster' in exc.value.args[0]['msg']
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.license_v2_add()
     assert 'Error adding license' in exc.value.args[0]['msg']
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.license_v2_delete()
         assert 'Error deleting license' in exc.value.args[0]['msg']
Пример #5
0
 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'])