コード例 #1
0
    def test_list_checkpoints__creates_rollbacker_and_list_checkpoints(self):
        # Arrange
        config_rollbacker = Mock()
        config_rollbacker.list_checkpoints.return_value = self.any_checkpoints_list

        factory = Mock()
        factory.create_config_rollbacker.side_effect = \
            create_side_effect_dict({(str(self.any_verbose),): config_rollbacker})

        generic_updater = gu.GenericUpdater(factory)

        expected = self.any_checkpoints_list

        # Act
        actual = generic_updater.list_checkpoints(self.any_verbose)

        # Assert
        self.assertCountEqual(expected, actual)
コード例 #2
0
    def test_delete_checkpoint__creates_rollbacker_and_deletes_checkpoint(
            self):
        # Arrange
        config_rollbacker = Mock()
        config_rollbacker.delete_checkpoint.side_effect = create_side_effect_dict(
            {(self.any_checkpoint_name, ): 0})

        factory = Mock()
        factory.create_config_rollbacker.side_effect = \
            create_side_effect_dict({(str(self.any_verbose),): config_rollbacker})

        generic_updater = gu.GenericUpdater(factory)

        # Act
        generic_updater.delete_checkpoint(self.any_checkpoint_name,
                                          self.any_verbose)

        # Assert
        config_rollbacker.delete_checkpoint.assert_has_calls(
            [call(self.any_checkpoint_name)])
コード例 #3
0
    def test_replace__creates_replacer_and_replace(self):
        # Arrange
        config_replacer = Mock()
        config_replacer.replace.side_effect = create_side_effect_dict({
            (str(Files.SONIC_YANG_AS_JSON), ):
            0
        })

        factory = Mock()
        factory.create_config_replacer.side_effect = \
            create_side_effect_dict(
                {(str(self.any_config_format), str(self.any_verbose), str(self.any_dry_run),): config_replacer})

        generic_updater = gu.GenericUpdater(factory)

        # Act
        generic_updater.replace(Files.SONIC_YANG_AS_JSON,
                                self.any_config_format, self.any_verbose,
                                self.any_dry_run)

        # Assert
        config_replacer.replace.assert_has_calls(
            [call(Files.SONIC_YANG_AS_JSON)])
コード例 #4
0
    def test_apply_patch__creates_applier_and_apply(self):
        # Arrange
        patch_applier = Mock()
        patch_applier.apply.side_effect = create_side_effect_dict({
            (str(Files.SINGLE_OPERATION_SONIC_YANG_PATCH), ):
            0
        })

        factory = Mock()
        factory.create_patch_applier.side_effect = \
            create_side_effect_dict(
                {(str(self.any_config_format), str(self.any_verbose), str(self.any_dry_run),): patch_applier})

        generic_updater = gu.GenericUpdater(factory)

        # Act
        generic_updater.apply_patch(Files.SINGLE_OPERATION_SONIC_YANG_PATCH,
                                    self.any_config_format, self.any_verbose,
                                    self.any_dry_run)

        # Assert
        patch_applier.apply.assert_has_calls(
            [call(Files.SINGLE_OPERATION_SONIC_YANG_PATCH)])