Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Jul 11, 2022
1 parent 9d8a309 commit b394be0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/test_keybindings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import sys

import pytest
from pydantic import BaseModel

from app_model.types import KeyBinding, KeyCode, KeyMod, SimpleKeyBinding
from app_model.types._keys import KeyChord, KeyCombo
from app_model.types import (
KeyBinding,
KeyBindingRule,
KeyCode,
KeyMod,
SimpleKeyBinding,
)
from app_model.types._keys import KeyChord, KeyCombo, StandardKeyBinding

MAC = sys.platform == "darwin"

Expand Down Expand Up @@ -68,8 +75,6 @@ def test_chord_keybinding():


def test_in_model():
from pydantic import BaseModel

class M(BaseModel):
key: KeyBinding

Expand All @@ -78,3 +83,11 @@ class Config:

m = M(key="Shift+A B")
assert m.json(models_as_dict=False) == '{"key": "Shift+A B"}'


def test_standard_keybindings():
class M(BaseModel):
key: KeyBindingRule

m = M(key=StandardKeyBinding.Copy)
assert m.key.primary == KeyMod.CtrlCmd | KeyCode.KeyC

0 comments on commit b394be0

Please sign in to comment.