def export_service(self, svc_ref, name, fw_uid): """ Endpoint registered """ service = self.context.get_service(svc_ref) endpoint = beans.ExportEndpoint(str(uuid.uuid4()), fw_uid, self.configs, name, svc_ref, service, {}) self.endpoints.append(endpoint) return endpoint
def testConvertBeans(self): """ Tests the conversion of an ExportEndpoint to an EndpointDescription and of an EndpointDescription to an ImportEndpoint bean """ # Prepare ExportEndpoint & ImportEndpoint beans specifications = self.svc_ref.get_property(pelix.constants.OBJECTCLASS) export_bean = beans.ExportEndpoint("some.endpoint.uid", "some.framework.uid", ["configurationA"], "some.endpoint.name", self.svc_ref, self.service, {"extra.property": 42}) import_bean = beans.ImportEndpoint( export_bean.uid, export_bean.framework, export_bean.configurations, export_bean.name, export_bean.specifications, export_bean.make_import_properties()) # Convert it to an EndpointDescription bean description_bean = beans.EndpointDescription.from_export(export_bean) # ... ensure its content is valid self.assertEqual(description_bean.get_id(), export_bean.uid) self.assertEqual(description_bean.get_framework_uuid(), export_bean.framework) self.assertEqual(description_bean.get_configuration_types(), export_bean.configurations) # ExportEndpoint specifications are prefixed by "python:/" self.assertEqual(description_bean.get_interfaces(), specifications) self.assertDictContainsSubset(export_bean.make_import_properties(), description_bean.get_properties()) # Convert the result to an ImportEndpoint bean descripted_import = description_bean.to_import() # ... ensure its content is valid for field in ('uid', 'framework', 'configurations', 'specifications'): self.assertEqual(getattr(descripted_import, field), getattr(import_bean, field)) self.assertDictContainsSubset(import_bean.properties, descripted_import.properties)