コード例 #1
0
    def setUp(self, mock_gfc, mock_ps):
        mock_module = self._mock_module()
        collectors = self._collectors(mock_module)

        fact_collector = \
            assible_collector.AssibleFactCollector(collectors=collectors,
                                                   namespace=ns)
        self.facts = fact_collector.collect(
            module=mock_module, collected_facts=self.collected_facts)
コード例 #2
0
    def _collect(self, _mock_module, collected_facts=None):
        _collectors = self._collectors(_mock_module)

        fact_collector = \
            assible_collector.AssibleFactCollector(collectors=_collectors,
                                                   namespace=ns,
                                                   filter_spec=_mock_module.params['filter'])
        facts_dict = fact_collector.collect(module=_mock_module,
                                            collected_facts=collected_facts)
        return facts_dict
コード例 #3
0
    def setUp(self):
        self.patcher = patch('platform.system')
        mock_platform = self.patcher.start()
        mock_platform.return_value = 'OpenBSD'

        mock_module = self._mock_module()
        collectors = self._collectors(mock_module)

        fact_collector = \
            assible_collector.AssibleFactCollector(collectors=collectors,
                                                   namespace=ns)
        self.facts = fact_collector.collect(module=mock_module)
コード例 #4
0
    def test1(self):
        gather_subset = ['all']
        mock_module = self._mock_module(gather_subset=gather_subset)
        collectors = self._collectors(mock_module)

        fact_collector = \
            assible_collector.AssibleFactCollector(collectors=collectors,
                                                   namespace=ns)

        res = fact_collector.collect(module=mock_module)
        self.assertIsInstance(res, dict)
        # just assert it's not almost empty
        # with run_command and get_file_content mock, many facts are empty, like network
        self.assertGreater(len(res), 20)
コード例 #5
0
    def test_empty_all_collector_classes(self):
        mock_module = self._mock_module()
        all_collector_classes = []

        collectors = self._collectors(
            mock_module, all_collector_classes=all_collector_classes)

        fact_collector = \
            assible_collector.AssibleFactCollector(collectors=collectors,
                                                   namespace=ns)

        res = fact_collector.collect()
        self.assertIsInstance(res, dict)
        # just assert it's not almost empty
        self.assertLess(len(res), 3)
コード例 #6
0
    def test_concat_collector(self):
        _mock_module = mock_module(gather_subset=['all', '!facter', '!ohai'])

        _collectors = self._collectors(_mock_module)
        _collectors.append(ConCatFactCollector())

        fact_collector = \
            assible_collector.AssibleFactCollector(collectors=_collectors,
                                                   namespace=ns,
                                                   filter_spec=_mock_module.params['filter'])

        collected_facts = {}
        facts_dict = fact_collector.collect(module=_mock_module,
                                            collected_facts=collected_facts)
        self.assertIn('concat_fact', facts_dict)
        self.assertTrue('THE_NEEDED_FACT_VALUE' in facts_dict['concat_fact'])
コード例 #7
0
    def test(self):
        gather_subset = ['all']
        mock_module = self._mock_module(gather_subset=gather_subset)
        all_collector_classes = [EnvFactCollector]
        collectors = self._collectors(
            mock_module, all_collector_classes=all_collector_classes)

        fact_collector = \
            assible_collector.AssibleFactCollector(collectors=collectors,
                                                   namespace=ns)

        res = fact_collector.collect(module=mock_module)
        self.assertIsInstance(res, dict)
        self.assertIn('env', res)
        self.assertIn('gather_subset', res)
        self.assertEqual(res['gather_subset'], ['all'])