from src.pipeline.default import DefaultPipeline from src.detections import NameDetection from src.input_parsers.interface import InputParser from src.detectors.interface import Detector from src.suppressors.interface import Suppressor from src.replacers.interface import ReplacerInterface from tempfile import NamedTemporaryFile class MockInputParser(InputParser): def parse(self, content): return "ala ma kota", {} class MockDetector(Detector): def detect(self, text, annotations): return [(0, 3, NameDetection())] class MockSuppressor(Suppressor): def suppress(self, annotations): return annotations class MockReplacer(ReplacerInterface): def replace(self, text, annotations): return "zbigniew ma kota", annotations def test_default_pipeline(): # TODO: Prepare mocks that will better test the pipeline pipeline = DefaultPipeline( MockInputParser(), {"mock_detector": MockDetector()}, MockSuppressor(), {"mock_replacer": MockReplacer()}, ) with NamedTemporaryFile() as f: assert pipeline.run(f.name) == "zbigniew ma kota"