File: test_types.py

package info (click to toggle)
app-model 0.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 700 kB
  • sloc: python: 5,484; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 686 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pytest
from pydantic import ValidationError

from app_model.types import Action, Icon


def test_icon_validate() -> None:
    assert Icon._validate('"fa6s.arrow_down"') == Icon(
        dark='"fa6s.arrow_down"', light='"fa6s.arrow_down"'
    )


def test_action_validation() -> None:
    with pytest.raises(ValidationError, match="'s!adf' is not a valid python_name"):
        Action(id="test", title="test", callback="s!adf")

    with pytest.raises(ValidationError):
        Action(id="test", title="test", callback=[])

    with pytest.raises(ValidationError, match=r"'x\.\<locals\>\:asdf' is not a valid"):
        Action(id="test", title="test", callback="x.<locals>:asdf")