Skip to content

Commit c3c5a7b

Browse files
committed
test(core): assert portable note paths and newlines
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 536ecac commit c3c5a7b

3 files changed

Lines changed: 15 additions & 22 deletions

File tree

tests/mcp/test_tool_read_note.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from basic_memory import db
1010
from basic_memory.mcp.tools import write_note, read_note
1111
from basic_memory.mcp.tools.read_note import _parse_opening_frontmatter
12-
from basic_memory.utils import normalize_newlines
1312
from tests.mcp.conftest import ContextState, ctx
1413

1514

@@ -611,7 +610,7 @@ async def test_note_unicode_content(app, test_project):
611610

612611
# Read back should preserve unicode
613612
result = await read_note("test/unicode-test", project=test_project.name)
614-
assert normalize_newlines(content) in result
613+
assert content in result
615614

616615

617616
@pytest.mark.asyncio

tests/mcp/test_tool_write_note.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from basic_memory.mcp.tools import write_note, read_note, delete_note
1111
from basic_memory.mcp.tools.write_note import _compose_workspace_project_route
1212
from basic_memory.repository.relation_repository import RelationRepository
13-
from basic_memory.utils import normalize_newlines
1413

1514

1615
# ---------------------------------------------------------------------------
@@ -144,7 +143,7 @@ async def test_write_note(app, test_project):
144143

145144
# Try reading it back via permalink
146145
content = await read_note("test/test-note", project=test_project.name)
147-
expected = normalize_newlines(
146+
expected = (
148147
dedent("""
149148
---
150149
title: Test Note
@@ -179,7 +178,7 @@ async def test_write_note_no_tags(app, test_project):
179178
assert f"[Session: Using project '{test_project.name}']" in result
180179
# Should be able to read it back
181180
content = await read_note("test/simple-note", project=test_project.name)
182-
expected = normalize_newlines(
181+
expected = (
183182
dedent("""
184183
---
185184
title: Simple Note
@@ -241,9 +240,8 @@ async def test_write_note_update_existing(app, test_project):
241240
# Try reading it back
242241
content = await read_note("test/test-note", project=test_project.name)
243242
assert (
244-
normalize_newlines(
245-
dedent(
246-
"""
243+
dedent(
244+
"""
247245
---
248246
title: Test Note
249247
type: note
@@ -256,10 +254,9 @@ async def test_write_note_update_existing(app, test_project):
256254
# Test
257255
This is an updated note
258256
"""
259-
)
260-
.format(permalink=f"{test_project.name}/test/test-note")
261-
.strip()
262257
)
258+
.format(permalink=f"{test_project.name}/test/test-note")
259+
.strip()
263260
== content
264261
)
265262

@@ -555,9 +552,8 @@ async def test_write_note_preserves_content_frontmatter(app, test_project):
555552
# Try reading it back via permalink
556553
content = await read_note("test/test-note", project=test_project.name)
557554
assert (
558-
normalize_newlines(
559-
dedent(
560-
"""
555+
dedent(
556+
"""
561557
---
562558
title: Test Note
563559
type: note
@@ -573,10 +569,9 @@ async def test_write_note_preserves_content_frontmatter(app, test_project):
573569
574570
This is a test note
575571
"""
576-
)
577-
.format(permalink=f"{test_project.name}/test/test-note")
578-
.strip()
579572
)
573+
.format(permalink=f"{test_project.name}/test/test-note")
574+
.strip()
580575
in content
581576
)
582577

@@ -711,7 +706,7 @@ async def test_write_note_with_custom_note_type(app, test_project):
711706

712707
# Verify the note type is correctly set in the frontmatter
713708
content = await read_note("guides/test-guide", project=test_project.name)
714-
expected = normalize_newlines(
709+
expected = (
715710
dedent("""
716711
---
717712
title: Test Guide

tests/schemas/test_schemas.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Tests for Pydantic schema validation and conversion."""
22

3-
import os
43
import pytest
54
from datetime import datetime, timedelta
65
from pydantic import ValidationError, BaseModel
@@ -21,7 +20,7 @@ def test_entity_project_name():
2120
"""Test creating EntityIn with minimal required fields."""
2221
data = {"title": "Test Entity", "directory": "test", "note_type": "knowledge"}
2322
entity = Entity.model_validate(data)
24-
assert entity.file_path == os.path.join("test", "Test Entity.md")
23+
assert entity.file_path == "test/Test Entity.md"
2524
assert entity.permalink == "test/test-entity"
2625
assert entity.note_type == "knowledge"
2726

@@ -30,7 +29,7 @@ def test_entity_project_id():
3029
"""Test creating EntityIn with minimal required fields."""
3130
data = {"project": 2, "title": "Test Entity", "directory": "test", "note_type": "knowledge"}
3231
entity = Entity.model_validate(data)
33-
assert entity.file_path == os.path.join("test", "Test Entity.md")
32+
assert entity.file_path == "test/Test Entity.md"
3433
assert entity.permalink == "test/test-entity"
3534
assert entity.note_type == "knowledge"
3635

@@ -44,7 +43,7 @@ def test_entity_non_markdown():
4443
"content_type": "text/plain",
4544
}
4645
entity = Entity.model_validate(data)
47-
assert entity.file_path == os.path.join("test", "Test Entity.txt")
46+
assert entity.file_path == "test/Test Entity.txt"
4847
assert entity.permalink == "test/test-entity"
4948
assert entity.note_type == "file"
5049

0 commit comments

Comments
 (0)