Exemplo n.º 1
0
 def test_successful_delete(self, delete_lun_map):
     ''' unmapping lun and testing idempotency '''
     data = self.set_default_args()
     data['state'] = 'absent'
     set_module_args(data)
     my_obj = my_module()
     if not self.onbox:
         my_obj.server = MockONTAPConnection('lun_map')
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     assert exc.value.args[0]['changed']
     delete_lun_map.assert_called_with()
     # to reset na_helper from remembering the previous 'changed' value
     my_obj = my_module()
     if not self.onbox:
         my_obj.server = self.server
     with pytest.raises(AnsibleExitJson) as exc:
         my_obj.apply()
     assert not exc.value.args[0]['changed']
Exemplo n.º 2
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.onbox:
         my_obj.server = MockONTAPConnection('lun_map_fail')
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.create_lun_map()
     assert 'Error mapping lun' in exc.value.args[0]['msg']
     with pytest.raises(AnsibleFailJson) as exc:
         my_obj.delete_lun_map()
     assert 'Error unmapping lun' in exc.value.args[0]['msg']
Exemplo n.º 3
0
 def test_ensure_get_called(self):
     ''' test get_lun_map for non-existent lun'''
     set_module_args(self.set_default_args())
     my_obj = my_module()
     my_obj.server = self.server
     assert my_obj.get_lun_map is not None
Exemplo n.º 4
0
 def test_ensure_get_called_existing(self):
     ''' test get_lun_map for existing lun'''
     set_module_args(self.set_default_args())
     my_obj = my_module()
     my_obj.server = MockONTAPConnection(kind='lun_map')
     assert my_obj.get_lun_map()
Exemplo n.º 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'])