def test_merge(self): target = Definitions() source = Definitions() source.types = Types() source.messages.append(Message()) source.port_types.append(PortType()) source.bindings.append(Binding()) source.services.append(Service()) source.extended.append(AnyElement()) source_two = copy.deepcopy(source) source_two.types.schemas.append(Schema()) target.merge(source) self.assertEqual(source.types, target.types) self.assertEqual(0, len(target.types.schemas)) self.assertEqual(1, len(target.messages)) self.assertEqual(1, len(target.port_types)) self.assertEqual(1, len(target.bindings)) self.assertEqual(1, len(target.services)) self.assertEqual(1, len(target.extended)) target.merge(source_two) target.merge(Definitions()) self.assertEqual(1, len(target.types.schemas)) self.assertEqual(2, len(target.messages)) self.assertEqual(2, len(target.port_types)) self.assertEqual(2, len(target.bindings)) self.assertEqual(2, len(target.services)) self.assertEqual(2, len(target.extended))
def test_property_schemas(self): obj = Definitions() self.assertIsInstance(obj.schemas, Generator) self.assertEqual([], list(obj.schemas)) obj.types = Types() self.assertEqual([], list(obj.schemas)) schemas = [Schema(), Schema] obj.types.schemas.extend(schemas) self.assertEqual(schemas, list(obj.schemas))