Add annotation tests for schema interface
This commit is contained in:
@@ -10,9 +10,15 @@ def addressbook():
|
||||
return capnp.load(os.path.join(this_dir, 'addressbook.capnp'))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def annotations():
|
||||
return capnp.load(os.path.join(this_dir, 'annotations.capnp'))
|
||||
|
||||
|
||||
def test_basic_schema(addressbook):
|
||||
assert addressbook.Person.schema.fieldnames[0] == 'id'
|
||||
|
||||
|
||||
def test_list_schema(addressbook):
|
||||
peopleField = addressbook.AddressBook.schema.fields['people']
|
||||
personType = peopleField.schema.elementType
|
||||
@@ -22,3 +28,19 @@ def test_list_schema(addressbook):
|
||||
personListSchema = capnp.ListSchema(addressbook.Person)
|
||||
|
||||
assert personListSchema.elementType.node.id == addressbook.Person.schema.node.id
|
||||
|
||||
|
||||
def test_annotations(annotations):
|
||||
assert annotations.schema.node.annotations[0].value.text == 'TestFile'
|
||||
|
||||
annotation = annotations.TestAnnotationOne.schema.node.annotations[0]
|
||||
assert annotation.value.text == 'Test'
|
||||
|
||||
annotation = annotations.TestAnnotationTwo.schema.node.annotations[0]
|
||||
assert annotation.value.struct.as_struct(annotations.AnnotationStruct).test == 100
|
||||
|
||||
annotation = annotations.TestAnnotationThree.schema.node.annotations[0]
|
||||
annotation_list = annotation.value.list.as_list(capnp.ListSchema(annotations.AnnotationStruct))
|
||||
assert annotation_list[0].test == 100
|
||||
assert annotation_list[1].test == 101
|
||||
|
||||
|
||||
Reference in New Issue
Block a user