def test_default_collectors(self):
        platform_info = {'system': 'Generic'}
        compat_platforms = [platform_info]
        collectors_for_platform = collector.find_collectors_for_platform(
            default_collectors.collectors, compat_platforms)

        all_fact_subsets, aliases_map = collector.build_fact_id_to_collector_map(
            collectors_for_platform)

        all_valid_subsets = frozenset(all_fact_subsets.keys())
        collector_names = collector.get_collector_names(
            valid_subsets=all_valid_subsets,
            aliases_map=aliases_map,
            platform_info=platform_info)
        complete_collector_names = collector._solve_deps(
            collector_names, all_fact_subsets)

        dep_map = collector.build_dep_data(complete_collector_names,
                                           all_fact_subsets)

        ordered_deps = collector.tsort(dep_map)
        ordered_collector_names = [x[0] for x in ordered_deps]

        res = collector.select_collector_classes(ordered_collector_names,
                                                 all_fact_subsets)

        self.assertTrue(
            res.index(default_collectors.ServiceMgrFactCollector) > res.index(
                default_collectors.DistributionFactCollector), res)
        self.assertTrue(
            res.index(default_collectors.ServiceMgrFactCollector) > res.index(
                default_collectors.PlatformFactCollector), res)
    def test_default_collectors(self):
        platform_info = {'system': 'Generic'}
        compat_platforms = [platform_info]
        collectors_for_platform = collector.find_collectors_for_platform(default_collectors.collectors,
                                                                         compat_platforms)

        all_fact_subsets, aliases_map = collector.build_fact_id_to_collector_map(collectors_for_platform)

        all_valid_subsets = frozenset(all_fact_subsets.keys())
        collector_names = collector.get_collector_names(valid_subsets=all_valid_subsets,
                                                        aliases_map=aliases_map,
                                                        platform_info=platform_info)
        complete_collector_names = collector._solve_deps(collector_names, all_fact_subsets)

        dep_map = collector.build_dep_data(complete_collector_names, all_fact_subsets)

        ordered_deps = collector.tsort(dep_map)
        ordered_collector_names = [x[0] for x in ordered_deps]

        res = collector.select_collector_classes(ordered_collector_names,
                                                 all_fact_subsets)

        self.assertTrue(res.index(default_collectors.ServiceMgrFactCollector) >
                        res.index(default_collectors.DistributionFactCollector),
                        res)
        self.assertTrue(res.index(default_collectors.ServiceMgrFactCollector) >
                        res.index(default_collectors.PlatformFactCollector),
                        res)
    def test(self):
        unresolved = set(['env', 'network'])
        all_fact_subsets = {'env': [default_collectors.EnvFactCollector],
                            'network': [default_collectors.LinuxNetworkCollector],
                            'virtual': [default_collectors.LinuxVirtualCollector],
                            'platform': [default_collectors.PlatformFactCollector],
                            'distribution': [default_collectors.DistributionFactCollector]}
        res = collector.resolve_requires(unresolved, all_fact_subsets)

        res = collector._solve_deps(unresolved, all_fact_subsets)

        self.assertIsInstance(res, set)
        for goal in unresolved:
            self.assertIn(goal, res)
    def test(self):
        unresolved = set(['env', 'network'])
        all_fact_subsets = {'env': [default_collectors.EnvFactCollector],
                            'network': [default_collectors.LinuxNetworkCollector],
                            'virtual': [default_collectors.LinuxVirtualCollector],
                            'platform': [default_collectors.PlatformFactCollector],
                            'distribution': [default_collectors.DistributionFactCollector]}
        res = collector.resolve_requires(unresolved, all_fact_subsets)

        res = collector._solve_deps(unresolved, all_fact_subsets)

        self.assertIsInstance(res, set)
        for goal in unresolved:
            self.assertIn(goal, res)