def test_root_elements(self): override = Override() redefine = Redefine() redefine.annotation = Annotation() redefine.complex_types.append(ComplexType()) override.annotation = Annotation() override.groups.append(Group()) override.simple_types.append(SimpleType()) schema = Schema() schema.simple_types.append(SimpleType()) schema.attribute_groups.append(AttributeGroup()) schema.groups.append(Group()) schema.attributes.append(Attribute()) schema.complex_types.append(ComplexType()) schema.elements.append(Element()) schema.redefines.append(redefine) schema.overrides.append(override) iterator = SchemaMapper.root_elements(schema) expected = [ ("Override", override.simple_types[0]), ("Override", override.groups[0]), ("Redefine", redefine.complex_types[0]), ("Schema", schema.simple_types[0]), ("Schema", schema.complex_types[0]), ("Schema", schema.groups[0]), ("Schema", schema.attribute_groups[0]), ("Schema", schema.elements[0]), ("Schema", schema.attributes[0]), ] self.assertEqual(expected, list(iterator))
def test_build(self, mock_build_class): schema = self.schema override = Override() redefine = Redefine() redefine.annotation = Annotation() redefine.complex_types.append(ComplexType()) override.annotation = Annotation() override.groups.append(Group()) override.simple_types.append(SimpleType()) schema.simple_types.append(SimpleType()) schema.attribute_groups.append(AttributeGroup()) schema.groups.append(Group()) schema.attributes.append(Attribute()) schema.complex_types.append(ComplexType()) schema.elements.append(Element()) schema.redefines.append(redefine) schema.overrides.append(override) self.builder.build() mock_build_class.assert_has_calls( [ mock.call(override.simple_types[0], container=override.class_name), mock.call(override.groups[0], container=override.class_name), mock.call(redefine.complex_types[0], container=redefine.class_name), mock.call(schema.simple_types[0], container=schema.class_name), mock.call(schema.complex_types[0], container=schema.class_name), mock.call(schema.groups[0], container=schema.class_name), mock.call(schema.attribute_groups[0], container=schema.class_name), mock.call(schema.elements[0], container=schema.class_name), mock.call(schema.attributes[0], container=schema.class_name), ] )