def test_build(self) -> None:
        cluster_group_builder = ClusterGroupBuilder(
            cluster_repository=self.cluster_repository,
            project_repository=self.project_repository)

        cluster_group = cluster_group_builder.build([self.cluster])

        self.assertEqual(self.cluster_group, cluster_group)
    def test_build_throws_exception_required_argument(self) -> None:
        cluster_group_builder = ClusterGroupBuilder(
            cluster_repository=self.cluster_repository,
            project_repository=self.project_repository)

        with self.assertRaises(Exception) as context:
            cluster_group_builder.build()

        self.assertTrue(
            'required positional argument' in str(context.exception))
예제 #3
0
    def setUp(self) -> None:
        self.source_locator = SourceLocator()
        self.source_repository = SourceRepository()
        self.cluster_repository = ClusterRepository()
        self.project_repository = ProjectRepository()
        self.enforcement_repository = EnforcementRepository()
        self.enforcement = Enforcement(name='test', repo='somewhere')

        self.cluster = Cluster(name='test',
                               url='test',
                               token='test',
                               id='test')
        self.cluster_group = ClusterGroup(
            clusters=[self.cluster],
            cluster_repository=self.cluster_repository,
            project_repository=self.project_repository)
        self.cluster_group_builder = ClusterGroupBuilder(
            cluster_repository=self.cluster_repository,
            project_repository=self.project_repository)
        self.cluster_rule = ClusterRule(enforcements=[],
                                        source=EnforcementSource())

        self.enforcement_installer_builder = EnforcementInstallerBuilder(
            enforcement_repository=self.enforcement_repository)

        self.enforcement_installer = EnforcementInstaller(
            enforcements=[self.enforcement],
            cluster_group=self.cluster_group,
            enforcement_repository=self.enforcement_repository)
예제 #4
0
    def setUp(self) -> None:
        self.dynamic_mapper = EnforcementDynamicMapper()
        self.cluster_repository = ClusterRepository()
        self.project_repository = ProjectRepository()
        self.enforcement_repository = EnforcementRepository()
        self.enforcement = Enforcement(name='test', repo='somewhere')
        self.old_enforcement = Enforcement(name='test', repo='somewhere')
        self.new_enforcement = Enforcement(name='test1', repo='anywhere')
        self.cluster = Cluster(name='test',
                               url='test',
                               token='test',
                               id='test')
        self.cluster_group = ClusterGroup(
            clusters=[self.cluster],
            cluster_repository=self.cluster_repository,
            project_repository=self.project_repository)

        self.cluster_group_builder = ClusterGroupBuilder(
            cluster_repository=self.cluster_repository,
            project_repository=self.project_repository)

        self.cluster_rule = ClusterRule(enforcements=[self.enforcement],
                                        source=EnforcementSource())

        trigger_builder = MagicMock()
        trigger_builder.build_before_install = MagicMock(
            return_value=lambda enf, cluster: None)
        trigger_builder.build_after_install = MagicMock(
            return_value=lambda enf, cluster: None)

        self.enforcement_installer_builder = EnforcementInstallerBuilder(
            enforcement_repository=self.enforcement_repository,
            enforcement_dynamic_mapper=EnforcementDynamicMapper(),
            trigger_builder=trigger_builder,
        )

        self.enforcement_installer = EnforcementInstaller(
            enforcements=[self.enforcement],
            cluster_group=self.cluster_group,
            enforcement_repository=self.enforcement_repository,
            enforcement_dynamic_mapper=self.dynamic_mapper,
            before_install_trigger=lambda a1, a2: None,
            after_install_trigger=lambda a1, a2: None,
        )

        self.enforcement_change_detector_builder = EnforcementChangeDetectorBuilder(
        )
        self.enforcement_change_detector = EnforcementChangeDetector(
            old_enforcements_list=[self.old_enforcement],
            new_enforcements_list=[self.new_enforcement])
예제 #5
0
 def provide_cluster_group_builder(
         self, cluster_repository: ClusterRepository,
         project_repository: ProjectRepository) -> ClusterGroupBuilder:
     return ClusterGroupBuilder(cluster_repository=cluster_repository,
                                project_repository=project_repository)