test_input_operations.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from collections.abc import Callable
  10. from materialize.output_consistency.input_data.operations.all_operations_provider import (
  11. ALL_OPERATION_TYPES,
  12. )
  13. from materialize.output_consistency.operation.operation import DbOperationOrFunction
  14. class ConsistencyTestOperationsInput:
  15. def __init__(
  16. self,
  17. ) -> None:
  18. self.all_operation_types: list[DbOperationOrFunction] = (
  19. self._get_without_disabled_operations(ALL_OPERATION_TYPES)
  20. )
  21. def _get_without_disabled_operations(
  22. self, operations: list[DbOperationOrFunction]
  23. ) -> list[DbOperationOrFunction]:
  24. filtered_operations = []
  25. for operation in operations:
  26. if operation.is_enabled:
  27. filtered_operations.append(operation)
  28. return filtered_operations
  29. def remove_functions(
  30. self, shall_remove: Callable[[DbOperationOrFunction], bool]
  31. ) -> None:
  32. self.all_operation_types = [
  33. op for op in self.all_operation_types if not shall_remove(op)
  34. ]