def test_successful_create(self, create_subsystem): ''' creating subsystem and testing idempotency ''' set_module_args(self.set_default_args()) my_obj = my_module() if not self.onbox: my_obj.server = self.server with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() assert exc.value.args[0]['changed'] create_subsystem.assert_called_with() # to reset na_helper from remembering the previous 'changed' value my_obj = my_module() if not self.onbox: my_obj.server = MockONTAPConnection('subsystem') with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() assert not exc.value.args[0]['changed']
def test_successful_add(self): ''' adding subsystem host/map and testing idempotency ''' set_module_args(self.set_default_args()) my_obj = my_module() if not self.onbox: my_obj.server = self.server with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() assert exc.value.args[0]['changed']
def test_successful_remove(self): ''' removing subsystem host/map and testing idempotency ''' data = self.set_default_args() data['paths'] = ['abcd/vol'] set_module_args(data) my_obj = my_module() if not self.onbox: my_obj.server = MockONTAPConnection('subsystem') with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() assert exc.value.args[0]['changed']
def test_successful_add_mock(self, add_subsystem_host_map): ''' adding subsystem host/map and testing idempotency ''' set_module_args(self.set_default_args()) my_obj = my_module() if not self.onbox: my_obj.server = self.server with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() assert exc.value.args[0]['changed'] add_subsystem_host_map.assert_called_with(['abcd/vol', 'xyz/vol'], 'paths')
def test_ensure_get_called_existing(self): ''' test get_subsystem_host_map() for existing subsystem''' set_module_args(self.set_default_args()) my_obj = my_module() my_obj.server = MockONTAPConnection(kind='subsystem') assert my_obj.get_subsystem_host_map('paths')
def test_ensure_get_called(self): ''' test get_subsystem_host_map() for non-existent subsystem''' set_module_args(self.set_default_args()) my_obj = my_module() my_obj.server = self.server assert my_obj.get_subsystem_host_map('paths') is None
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'])