from streamer.parse import StreamFile, parse_markdown_file, Shard from faker import Faker fake = Faker() class TestParseProcess: file_name: str = fake.file_name(extension="md") def test_parse_empty_file(self): assert parse_markdown_file(self.file_name, "") == StreamFile( filename=self.file_name, shard=None ) def test_parse_basic_one_line_file(self): test_file = "Hello World" assert parse_markdown_file(self.file_name, test_file) == StreamFile( filename=self.file_name, shard=Shard( markers=[], tags=[], content=test_file, start_line=1, end_line=1, children=[], ), ) def test_parse_basic_multi_line_file(self): test_file = "Hello World\nHello again!" assert parse_markdown_file(self.file_name, test_file) == StreamFile( filename=self.file_name, shard=Shard( markers=[], tags=[], content=test_file, start_line=1, end_line=2, children=[], ), ) def test_parse_single_line_with_tag(self): test_file = "@Tag Hello World" assert parse_markdown_file(self.file_name, test_file) == StreamFile( filename=self.file_name, shard=Shard( markers=["Tag"], tags=[], content=test_file, start_line=1, end_line=1, children=[], ), ) def test_parse_single_line_with_two_tags(self): test_file = "@Tag1 @Tag2 Hello World" assert parse_markdown_file(self.file_name, test_file) == StreamFile( filename=self.file_name, shard=Shard( markers=["Tag1", "Tag2"], tags=[], content=test_file, start_line=1, end_line=1, children=[], ), ) def test_parse_single_line_with_two_tags_and_misplaced_tag(self): test_file = "@Tag1 @Tag2 Hello World @Tag3" assert parse_markdown_file(self.file_name, test_file) == StreamFile( filename=self.file_name, shard=Shard( markers=["Tag1", "Tag2"], tags=["Tag3"], content=test_file, start_line=1, end_line=1, children=[], ), )