2026-02-19 20:38:29 +01:00
|
|
|
from typing import TypedDict
|
|
|
|
|
import pytest
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
from teilchensammler_cli.models import TeilchenCreate, make_teilchen_input
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
2026-02-16 21:11:35 +01:00
|
|
|
def test_initial_layout(snap_compare):
|
2026-01-08 12:08:13 +01:00
|
|
|
from teilchensammler_cli.main import app
|
|
|
|
|
|
|
|
|
|
assert snap_compare(app, terminal_size=(130, 40))
|
2026-02-19 20:38:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Teilchen(TypedDict):
|
|
|
|
|
"""The things I do for my LSP..."""
|
|
|
|
|
|
|
|
|
|
name: str
|
|
|
|
|
description: str
|
|
|
|
|
tags: str
|
|
|
|
|
text: str
|
|
|
|
|
number: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
empty_teilchen: Teilchen = {
|
|
|
|
|
"name": "",
|
|
|
|
|
"description": "",
|
|
|
|
|
"tags": "",
|
|
|
|
|
"text": "",
|
|
|
|
|
"number": 1,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
"example_input,expected",
|
|
|
|
|
[
|
|
|
|
|
("", None),
|
|
|
|
|
("a", None),
|
|
|
|
|
("a.", {"name": "a", "text": "a."}),
|
|
|
|
|
("aa", None),
|
|
|
|
|
("aa.", {"name": "aa", "text": "aa."}),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
async def test_teilchendata_must_include_period(
|
|
|
|
|
example_input: str, expected: dict[str, str | int] | None
|
|
|
|
|
) -> None:
|
|
|
|
|
|
|
|
|
|
thing = expected
|
|
|
|
|
if expected:
|
|
|
|
|
arguments = empty_teilchen | expected
|
|
|
|
|
thing = TeilchenCreate(**arguments) # ty:ignore[invalid-argument-type]
|
|
|
|
|
|
|
|
|
|
assert await make_teilchen_input(example_input) == thing
|