File: test_constraints.py

package info (click to toggle)
python-apischema 0.18.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,636 kB
  • sloc: python: 15,281; makefile: 3; sh: 2
file content (11 lines) | stat: -rw-r--r-- 430 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
from apischema.constraints import merge_constraints
from apischema.schemas import Constraints


def test_constraint_merging():
    constraints = Constraints(min=1, max=10)
    other = Constraints(min=0, max=5)
    assert merge_constraints(constraints, other) == Constraints(min=1, max=5)
    base_schema = {"minimum": 0, "maximum": 5}
    constraints.merge_into(base_schema)
    assert base_schema == {"minimum": 1, "maximum": 5}