Exemplo n.º 1
0
    def test_static_attributes(self):
        with patch('SaltGenResource.SaltNodesCommandParser', MockParser()) as parser:
            with patch('salt.client.Caller', MockCaller()) as caller:
                call_kwargs = dict.copy(self.default_kwargs)
                parser.options.include_server_node = self.include_server_node
                call_kwargs['exclude_minion'] = self.include_server_node

                parser.args = ['color=yellow', 'pattern=\'polka dot\'']
                resources = ResourceGenerator().run()

                self._test_required_attributes(resources)
                self._test_attributes(resources, ['color', 'pattern'])

                for host, attributes in resources.iteritems():
                    self.assertEqual(resources[host]['color'], 'yellow')
                    self.assertEqual(resources[host]['pattern'], 'polka dot')

                caller.cmd.assert_called_once_with(*self.default_args, **call_kwargs)
Exemplo n.º 2
0
    def test_static_username(self):
        with patch('SaltGenResource.SaltNodesCommandParser', MockParser()) as parser:
            with patch('salt.client.Caller', MockCaller()) as caller:
                call_kwargs = dict.copy(self.default_kwargs)
                parser.options.include_server_node = self.include_server_node
                call_kwargs['exclude_minion'] = self.include_server_node

                parser.args = ['username=root']
                resources = ResourceGenerator().run()

                self._test_required_attributes(resources)
                self._test_attributes(resources, ['username'])

                for host, attributes in resources.iteritems():
                    if host == ResourceGenerator._server_node_name:
                        self.assertEqual(resources[host]['username'], parser.options.server_node_user)
                    else:
                        self.assertEqual(resources[host]['username'], 'root')

                caller.cmd.assert_called_once_with(*self.default_args, **call_kwargs)