diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-26 14:05:40 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-26 14:05:40 -0500 |
| commit | 70e89e946cbdff307284d11a46558161f713607c (patch) | |
| tree | c305ce9249fac0aef1318f5caabae0df31be7e95 /pocketbook/tests/test_note.py | |
| parent | 92f4a9394ae1b662d037a3016e94058a3881bdb8 (diff) | |
| download | archsetup-70e89e946cbdff307284d11a46558161f713607c.tar.gz archsetup-70e89e946cbdff307284d11a46558161f713607c.zip | |
refactor: fold pocketbook in-tree and drop its install steps
Pocketbook is nowhere near ready, so I pulled it back from publication: deleted the github mirror and the cjennings.net repo, removed the server mirror hook, and copied the package into pocketbook/ here until it's ready to spin back out.
Dropped the steps that provisioned it on a fresh install: the gtk4-layer-shell dep and the pip install in archsetup, and the clone in post-install.sh. That clone pointed at the now-deleted github repo, so it would have failed a fresh run regardless. Re-wiring the install is tracked in the pocketbook backlog.
Diffstat (limited to 'pocketbook/tests/test_note.py')
| -rw-r--r-- | pocketbook/tests/test_note.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/pocketbook/tests/test_note.py b/pocketbook/tests/test_note.py new file mode 100644 index 0000000..539451a --- /dev/null +++ b/pocketbook/tests/test_note.py @@ -0,0 +1,69 @@ +from pocketbook.note import Note + + +class TestNoteSerialisation: + def test_round_trip(self): + note = Note(title="Shopping", body="Milk\nEggs\nBread") + content = note.to_file_content() + restored = Note.from_file_content(content) + assert restored.title == note.title + assert restored.body == note.body + + def test_empty_body(self): + note = Note(title="Empty", body="") + content = note.to_file_content() + restored = Note.from_file_content(content) + assert restored.title == "Empty" + assert restored.body == "" + + def test_empty_title(self): + note = Note(title="", body="some body") + content = note.to_file_content() + restored = Note.from_file_content(content) + assert restored.title == "" + assert restored.body == "some body" + + def test_unicode(self): + note = Note(title="日本語タイトル", body="Ünïcödé bödý 🎉") + content = note.to_file_content() + restored = Note.from_file_content(content) + assert restored.title == "日本語タイトル" + assert restored.body == "Ünïcödé bödý 🎉" + + def test_multiline_body(self): + body = "Line 1\nLine 2\n\nLine 4\n" + note = Note(title="Multi", body=body) + content = note.to_file_content() + restored = Note.from_file_content(content) + assert restored.body == body + + def test_file_content_format(self): + """Title on line 1, blank line, then body.""" + note = Note(title="Title", body="Body text") + content = note.to_file_content() + assert content == "Title\n\nBody text" + + def test_from_file_content_no_blank_line(self): + """Gracefully handle files without a blank separator.""" + restored = Note.from_file_content("JustTitle") + assert restored.title == "JustTitle" + assert restored.body == "" + + +class TestNoteFilename: + def test_generate_filename(self): + note = Note(title="Test", body="") + filename = note.generate_filename(order=1) + assert filename.startswith("0001-") + assert filename.endswith(".txt") + # Format: 0001-YYYYMMDD-HHMMSS-shortid.txt + parts = filename.split("-") + assert len(parts) == 4 + assert len(parts[0]) == 4 # order + assert len(parts[1]) == 8 # date + # parts[2] = HHMMSS + shortid.txt combined via split on - + # Actually: 0001-20260225-143012-abc12.txt has 4 parts + + def test_parse_order_from_filename(self): + assert Note.parse_order("0005-20260101-120000-abc12.txt") == 5 + assert Note.parse_order("0001-20260101-120000-xyz99.txt") == 1 |
