Пример #1
0
 def test_ensure_portset_apply_called(self):
     ''' a more interesting test '''
     module_args = {'name': 'create'}
     module_args.update(self.set_default_args())
     set_module_args(module_args)
     my_obj = my_module()
     if not self.use_vsim:
         my_obj.server = self.server
     portset = my_obj.portset_get()
     print('Info: test_portset_get: %s' % repr(portset))
     assert portset is None
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_portset_apply: %s' % repr(exc.value))
     assert exc.value.args[0]['changed']
     if not self.use_vsim:
         my_obj.server = MockONTAPConnection('portset', 'create', 'vserver',
                                             'mixed')
     portset = my_obj.portset_get()
     print('Info: test_portset_get: %s' % repr(portset))
     assert portset is not None
     assert 'create' == portset['portset_name']
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_portset_apply: %s' % repr(exc.value))
     assert exc.value.args[0]['changed']
     portset = my_obj.portset_get()
     assert 'create' == portset['portset_name']
Пример #2
0
 def test_ensure_portset_get_called(self):
     ''' a more interesting test '''
     set_module_args(self.set_default_args())
     my_obj = my_module()
     my_obj.server = self.server
     portset = my_obj.portset_get()
     print('Info: test_portset_get: %s' % repr(portset))
     assert portset is None
Пример #3
0
 def test_delete_portset(self):
     ''' Test successful delete '''
     module_args = {'state': 'absent'}
     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('portset')
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_portset_apply: %s' % repr(exc.value))
     assert exc.value.args[0]['changed']
Пример #4
0
 def test_modify_ports(self):
     ''' Test modify_portset method '''
     module_args = {'ports': ['l1', 'l2']}
     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('portset')
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     print('Info: test_portset_apply: %s' % repr(exc.value))
     assert exc.value.args[0]['changed']
Пример #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'])