Esempio n. 1
0
    def test_undefined(self):
        undefined_object = AnsibleUndefined()
        try:
            yaml_out = self._dump_string(undefined_object, dumper=self.dumper)
        except UndefinedError:
            yaml_out = None

        self.assertIsNone(yaml_out)
Esempio n. 2
0
    def raw_get(self, host_name):
        '''
        Similar to __getitem__, however the returned data is not run through
        the templating engine to expand variables in the hostvars.
        '''
        host = self._find_host(host_name)
        if host is None:
            return AnsibleUndefined(name="hostvars['%s']" % host_name)

        return self._variable_manager.get_vars(host=host,
                                               include_hostvars=False)
Esempio n. 3
0
    def test_getattr(self):
        val = AnsibleUndefined()

        self.assertIs(getattr(val, 'foo'), val)

        self.assertRaises(AttributeError, getattr, val, '__UNSAFE__')
Esempio n. 4
0
 def test_is_unsafe(self):
     context = self._context()
     self.assertFalse(context._is_unsafe(AnsibleUndefined()))