当前位置: 首页>>代码示例>>Python>>正文


Python iorg_management_service.OrgManagementServiceClient类代码示例

本文整理汇总了Python中interface.services.coi.iorg_management_service.OrgManagementServiceClient的典型用法代码示例。如果您正苦于以下问题:Python OrgManagementServiceClient类的具体用法?Python OrgManagementServiceClient怎么用?Python OrgManagementServiceClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OrgManagementServiceClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_extended_user_identity

    def test_get_extended_user_identity(self):

        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        user_credentials_obj = IonObject("UserCredentials", {"name": self.subject})
        self.identity_management_service.register_user_credentials(user_id, user_credentials_obj)

        user_info_obj = IonObject("UserInfo", {"name": "Foo"})
        user_info = self.identity_management_service.create_user_info(user_id, user_info_obj)

        org_client = OrgManagementServiceClient(node=self.container.node)
        ion_org = org_client.find_org()

        extended_user = self.identity_management_service.get_actor_identity_extension(user_id, ion_org._id)
        self.assertEqual(actor_identity_obj.type_,extended_user.resource.type_)
        self.assertEqual(len(extended_user.roles),1)

        extended_user = self.identity_management_service.get_actor_identity_extension(user_id)
        self.assertEqual(actor_identity_obj.type_,extended_user.resource.type_)
        self.assertEqual(len(extended_user.roles),0)

        self.identity_management_service.delete_user_info(user_info)

        self.identity_management_service.unregister_user_credentials(user_id, self.subject)

        self.identity_management_service.delete_actor_identity(user_id)
开发者ID:pombredanne,项目名称:coi-services,代码行数:27,代码来源:test_identity_management_service.py

示例2: setUp

    def setUp(self):

        # Start container
        self._start_container()
        self.container.start_rel_from_url('res/deploy/r2coi.yml')

        self.org_management_service = OrgManagementServiceClient(node=self.container.node)
开发者ID:dstuebe,项目名称:coi-services,代码行数:7,代码来源:test_org_management_service.py

示例3: setUp

    def setUp(self):

        # Start container
        self._start_container()
        self.container.start_rel_from_url("res/deploy/r2coi.yml")

        self.resource_registry = ResourceRegistryServiceClient(node=self.container.node)
        self.org_management_service = OrgManagementServiceClient(node=self.container.node)
开发者ID:edwardhunter2,项目名称:coi-services,代码行数:8,代码来源:test_org_management_service.py

示例4: setUp

    def setUp(self):
        self.subject = "/DC=org/DC=cilogon/C=US/O=ProtectNetwork/CN=Roger Unwin A254"

        # Start container
        self._start_container()
        self.container.start_rel_from_url('res/deploy/r2coi.yml')

        self.identity_management_service = IdentityManagementServiceClient(node=self.container.node)
        self.org_client = OrgManagementServiceClient(node=self.container.node)
开发者ID:blazetopher,项目名称:coi-services,代码行数:9,代码来源:test_identity_management_service.py

示例5: setUp

    def setUp(self):

        # Start container
        self._start_container()

        # Establish endpoint with container
        container_client = ContainerAgentClient(node=self.container.node, name=self.container.name)
        container_client.start_rel_from_url('res/deploy/r2coi.yml')

        self.org_management_service = OrgManagementServiceClient(node=self.container.node)
开发者ID:daf,项目名称:coi-services,代码行数:10,代码来源:test_org_management_service.py

示例6: setUp

    def setUp(self):
        # Start container
        #print 'instantiating container'
        self._start_container()
        #container = Container()
        #print 'starting container'
        #container.start()
        #print 'started container'

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')
        self.RR = ResourceRegistryServiceClient(node=self.container.node)
        self.OMS = ObservatoryManagementServiceClient(node=self.container.node)
        self.org_management_service = OrgManagementServiceClient(node=self.container.node)
        self.instrument_management_service =  InstrumentManagementServiceClient(node=self.container.node)
开发者ID:tomoreilly,项目名称:coi-services,代码行数:14,代码来源:test_observatory_management_service_integration.py

示例7: setUp

    def setUp(self):
        # Start container
        #print 'instantiating container'
        self._start_container()
        #container = Container()
        #print 'starting container'
        #container.start()
        #print 'started container'

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')
        self.RR = ResourceRegistryServiceClient(node=self.container.node)
        self.OMS = ObservatoryManagementServiceClient(node=self.container.node)
        self.org_management_service = OrgManagementServiceClient(node=self.container.node)
        self.IMS =  InstrumentManagementServiceClient(node=self.container.node)
        self.dpclient = DataProductManagementServiceClient(node=self.container.node)
        self.pubsubcli =  PubsubManagementServiceClient(node=self.container.node)
        self.damsclient = DataAcquisitionManagementServiceClient(node=self.container.node)
        self.dataset_management = DatasetManagementServiceClient()
        #print 'TestObservatoryManagementServiceIntegration: started services'

        self.event_publisher = EventPublisher()
开发者ID:blazetopher,项目名称:coi-services,代码行数:21,代码来源:test_observatory_management_service_integration.py

示例8: TestOrgManagementServiceInt

class TestOrgManagementServiceInt(IonIntegrationTestCase):
    def setUp(self):

        # Start container
        self._start_container()
        self.container.start_rel_from_url("res/deploy/r2coi.yml")

        self.resource_registry = ResourceRegistryServiceClient(node=self.container.node)
        self.org_management_service = OrgManagementServiceClient(node=self.container.node)

    def test_org_crud(self):

        with self.assertRaises(BadRequest) as br:
            self.org_management_service.create_org(
                IonObject("Org", {"name": "Test Facility", "org_governance_name": "Test Facility"})
            )
        self.assertTrue("can only contain alphanumeric and underscore characters" in br.exception.message)

        with self.assertRaises(BadRequest):
            self.org_management_service.create_org()

        org_obj = IonObject("Org", {"name": "Test Facility"})
        org_id = self.org_management_service.create_org(org_obj)
        self.assertNotEqual(org_id, None)

        org = None
        org = self.org_management_service.read_org(org_id)
        self.assertNotEqual(org, None)
        self.assertEqual(org.org_governance_name, "Test_Facility")

        # Check that the roles got associated to them
        role_list = self.org_management_service.find_org_roles(org_id)
        self.assertEqual(len(role_list), 2)

        with self.assertRaises(BadRequest):
            self.org_management_service.update_org()
        org.name = "Updated Test Facility"
        self.org_management_service.update_org(org)

        org = None
        org = self.org_management_service.read_org(org_id)
        self.assertNotEqual(org, None)
        self.assertEqual(org.name, "Updated Test Facility")
        self.assertEqual(org.org_governance_name, "Test_Facility")

        user_role = self.org_management_service.find_org_role_by_name(org_id, ORG_MANAGER_ROLE)
        self.assertNotEqual(user_role, None)

        self.org_management_service.remove_user_role(org_id, ORG_MANAGER_ROLE)
        with self.assertRaises(BadRequest) as cm:
            user_role = self.org_management_service.find_org_role_by_name(org_id, ORG_MANAGER_ROLE)
        self.assertIn("The User Role 'ORG_MANAGER' does not exist for this Org", cm.exception.message)

        with self.assertRaises(BadRequest):
            self.org_management_service.delete_org()
        self.org_management_service.delete_org(org_id)

        with self.assertRaises(NotFound) as cm:
            self.org_management_service.read_org(org_id)
        self.assertIn("does not exist", cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.org_management_service.delete_org(org_id)
        self.assertIn("does not exist", cm.exception.message)

    def test_org_affiliation(self):

        root_org = None
        root_org = self.org_management_service.find_org()
        self.assertNotEqual(root_org, None)

        org_obj = IonObject("Org", {"name": "TestFacility"})
        org_id = self.org_management_service.create_org(org_obj)
        self.assertNotEqual(org_id, None)

        ret = self.org_management_service.affiliate_org(root_org._id, org_id)
        self.assertTrue(ret)

        ret = self.org_management_service.unaffiliate_org(root_org._id, org_id)
        self.assertTrue(ret)

    def test_find_org_containers(self):

        root_org = None
        root_org = self.org_management_service.find_org()
        self.assertNotEqual(root_org, None)

        containers = self.org_management_service.find_org_containers(root_org._id)

        all_containers, _ = self.resource_registry.find_resources(restype=RT.CapabilityContainer, id_only=True)

        self.assertEqual(len(containers), len(all_containers))
开发者ID:edwardhunter2,项目名称:coi-services,代码行数:92,代码来源:test_org_management_service.py

示例9: TestOrgManagementServiceInt

class TestOrgManagementServiceInt(IonIntegrationTestCase):

    def setUp(self):

        # Start container
        self._start_container()

        # Establish endpoint with container
        container_client = ContainerAgentClient(node=self.container.node, name=self.container.name)
        container_client.start_rel_from_url('res/deploy/r2coi.yml')

        self.org_management_service = OrgManagementServiceClient(node=self.container.node)


    def test_org_crud(self):
        org_obj = IonObject("Org", {"name": "Test Facility"})
        org_id = self.org_management_service.create_org(org_obj)
        self.assertNotEqual(org_id, None)

        org = None
        org = self.org_management_service.read_org(org_id)
        self.assertNotEqual(org, None)


        org.name = 'Updated Test Facility'
        self.org_management_service.update_org(org)

        org = None
        org = self.org_management_service.read_org(org_id)
        self.assertNotEqual(org, None)
        self.assertEqual(org.name, 'Updated Test Facility')

        self.org_management_service.delete_org(org_id)

        with self.assertRaises(NotFound) as cm:
            self.org_management_service.read_org(org_id)
        self.assertIn("does not exist", cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.org_management_service.delete_org(org_id)
        self.assertIn("does not exist", cm.exception.message)


    def test_org_affiliation(self):

        root_org = None
        root_org = self.org_management_service.find_org()
        self.assertNotEqual(root_org, None)

        org_obj = IonObject("Org", {"name": "Test Facility"})
        org_id = self.org_management_service.create_org(org_obj)
        self.assertNotEqual(org_id, None)

        ret = self.org_management_service.affiliate_org(root_org._id, org_id)
        self.assertTrue(ret)

        ret = self.org_management_service.unaffiliate_org(root_org._id, org_id)
        self.assertTrue(ret)
开发者ID:daf,项目名称:coi-services,代码行数:58,代码来源:test_org_management_service.py

示例10: TestIdentityManagementServiceInt

class TestIdentityManagementServiceInt(IonIntegrationTestCase):
    
    def setUp(self):
        self.subject = "/DC=org/DC=cilogon/C=US/O=ProtectNetwork/CN=Roger Unwin A254"

        # Start container
        self._start_container()
        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        self.resource_registry = ResourceRegistryServiceClient(node=self.container.node)
        self.identity_management_service = IdentityManagementServiceClient(node=self.container.node)
        self.org_client = OrgManagementServiceClient(node=self.container.node)

    def test_actor_identity(self):
        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})        
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        actor_identity = self.identity_management_service.read_actor_identity(user_id)

        actor_identity.name = 'Updated subject'
        self.identity_management_service.update_actor_identity(actor_identity)

        ai = self.identity_management_service.find_actor_identity_by_name(actor_identity.name)
        self._baseAssertEqual(ai.name, actor_identity.name)
        with self.assertRaises(NotFound):
            ai = self.identity_management_service.find_actor_identity_by_name("Yeah, well, you know, that's just, like, your opinion, man.")

        self._baseAssertEqual(ai.name, actor_identity.name)

        self.identity_management_service.delete_actor_identity(user_id)
 
        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.read_actor_identity(user_id)
        self.assertTrue("does not exist" in cm.exception.message)
 
        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.delete_actor_identity(user_id)
        self.assertTrue("does not exist" in cm.exception.message)

    def test_user_credentials(self):
        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})        
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        user_credentials_obj = IonObject("UserCredentials", {"name": self.subject})        
        self.identity_management_service.register_user_credentials(user_id, user_credentials_obj)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.unregister_user_credentials("bad", self.subject)
        self.assertTrue("does not exist" in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.unregister_user_credentials(user_id, "bad")
        self.assertTrue("does not exist" in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.unregister_user_credentials('bad', 'bad')
        self.assertTrue("does not exist" in cm.exception.message)

        self.identity_management_service.unregister_user_credentials(user_id, self.subject)

        self.identity_management_service.delete_actor_identity(user_id)




    def test_user_info(self):
        actor_identity_obj = IonObject("ActorIdentity", {"name": self.subject})
        user_id = self.identity_management_service.create_actor_identity(actor_identity_obj)

        user_credentials_obj = IonObject("UserCredentials", {"name": self.subject})
        self.identity_management_service.register_user_credentials(user_id, user_credentials_obj)

        user_info_obj = IonObject("UserInfo", {"name": "Foo"})
        user_info = self.identity_management_service.create_user_info(user_id, user_info_obj)

        with self.assertRaises(Conflict) as cm:
            self.identity_management_service.create_user_info(user_id, user_info_obj)
        self.assertTrue("UserInfo already exists for user id" in cm.exception.message)

        user_info_obj = self.identity_management_service.find_user_info_by_id(user_id)

        user_info_obj = self.identity_management_service.find_user_info_by_name("Foo")

        user_info_obj = self.identity_management_service.find_user_info_by_subject(self.subject)

        user_info_obj = self.identity_management_service.read_user_info(user_info)

        user_info_obj.name = 'Jane Doe'

        self.identity_management_service.update_user_info(user_info_obj)

        self.identity_management_service.delete_user_info(user_info)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.read_user_info(user_info)
        self.assertTrue('does not exist' in cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.identity_management_service.delete_user_info(user_info)
        self.assertTrue('does not exist' in cm.exception.message)
#.........这里部分代码省略.........
开发者ID:lukecampbell,项目名称:coi-services,代码行数:101,代码来源:test_identity_management_service.py

示例11: test_user_role_cache

    def test_user_role_cache(self):
        # Create a user
        id_client = IdentityManagementServiceClient()

        actor_id, valid_until, registered = id_client.signon(USER1_CERTIFICATE, True)

        # Make a request with this new user  to get it into the cache
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=TestDataProduct&id_only=True&requester=" + actor_id
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])

        # Check the contents of the user role cache for this user
        service_gateway_user_role_cache = self.container.proc_manager.procs_by_name["service_gateway"].user_role_cache
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), True)

        role_header = service_gateway_user_role_cache.get(actor_id)
        self.assertIn("ION", role_header)
        self.assertEqual(len(role_header["ION"]), 1)
        self.assertIn("ORG_MEMBER", role_header["ION"])

        org_client = OrgManagementServiceClient()

        ion_org = org_client.find_org()
        manager_role = org_client.find_org_role_by_name(org_id=ion_org._id, role_name="ORG_MANAGER")

        org_client.grant_role(org_id=ion_org._id, actor_id=actor_id, role_name="ORG_MANAGER")

        # Just allow some time for event processing on slower platforms
        gevent.sleep(2)

        # The user should be evicted from the cache due to a change in roles
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), False)

        # Do it again to check for new roles
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=TestDataProduct&id_only=True&requester=" + actor_id
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])

        # Check the contents of the user role cache for this user
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), True)

        role_header = service_gateway_user_role_cache.get(actor_id)
        self.assertIn("ION", role_header)
        self.assertEqual(len(role_header["ION"]), 2)
        self.assertIn("ORG_MEMBER", role_header["ION"])
        self.assertIn("ORG_MANAGER", role_header["ION"])

        # Now flush the user_role_cache and make sure it was flushed
        event_publisher = EventPublisher()
        event_publisher.publish_event(event_type=OT.UserRoleCacheResetEvent)

        # Just allow some time for event processing on slower platforms
        gevent.sleep(2)

        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), False)
        self.assertEqual(service_gateway_user_role_cache.size(), 0)

        # Change the role once again and see if it is there again
        org_client.revoke_role(org_id=ion_org._id, actor_id=actor_id, role_name="ORG_MANAGER")

        # Just allow some time for event processing on slower platforms
        gevent.sleep(2)

        # The user should still not be there
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), False)

        # Do it again to check for new roles
        response = self.test_app.get(
            "/ion-service/resource_registry/find_resources?name=TestDataProduct&id_only=True&requester=" + actor_id
        )
        self.check_response_headers(response)
        self.assertIn(GATEWAY_RESPONSE, response.json["data"])

        # Check the contents of the user role cache for this user
        self.assertEqual(service_gateway_user_role_cache.has_key(actor_id), True)

        role_header = service_gateway_user_role_cache.get(actor_id)
        self.assertIn("ION", role_header)
        self.assertEqual(len(role_header["ION"]), 1)
        self.assertIn("ORG_MEMBER", role_header["ION"])

        id_client.delete_actor_identity(actor_id)
开发者ID:edwardhunter2,项目名称:coi-services,代码行数:86,代码来源:test_service_gateway_service.py

示例12: TestObservatoryManagementServiceIntegration

class TestObservatoryManagementServiceIntegration(IonIntegrationTestCase):

    def setUp(self):
        # Start container
        #print 'instantiating container'
        self._start_container()
        #container = Container()
        #print 'starting container'
        #container.start()
        #print 'started container'

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')
        self.RR = ResourceRegistryServiceClient(node=self.container.node)
        self.RR2 = EnhancedResourceRegistryClient(self.RR)
        self.OMS = ObservatoryManagementServiceClient(node=self.container.node)
        self.org_management_service = OrgManagementServiceClient(node=self.container.node)
        self.IMS =  InstrumentManagementServiceClient(node=self.container.node)
        self.dpclient = DataProductManagementServiceClient(node=self.container.node)
        self.pubsubcli =  PubsubManagementServiceClient(node=self.container.node)
        self.damsclient = DataAcquisitionManagementServiceClient(node=self.container.node)
        self.dataset_management = DatasetManagementServiceClient()
        #print 'TestObservatoryManagementServiceIntegration: started services'

        self.event_publisher = EventPublisher()

#    @unittest.skip('this exists only for debugging the launch process')
#    def test_just_the_setup(self):
#        return

    def destroy(self, resource_ids):
        self.OMS.force_delete_observatory(resource_ids.observatory_id)
        self.OMS.force_delete_subsite(resource_ids.subsite_id)
        self.OMS.force_delete_subsite(resource_ids.subsite2_id)
        self.OMS.force_delete_subsite(resource_ids.subsiteb_id)
        self.OMS.force_delete_subsite(resource_ids.subsitez_id)
        self.OMS.force_delete_platform_site(resource_ids.platform_site_id)
        self.OMS.force_delete_platform_site(resource_ids.platform_siteb_id)
        self.OMS.force_delete_platform_site(resource_ids.platform_siteb2_id)
        self.OMS.force_delete_platform_site(resource_ids.platform_site3_id)
        self.OMS.force_delete_instrument_site(resource_ids.instrument_site_id)
        self.OMS.force_delete_instrument_site(resource_ids.instrument_site2_id)
        self.OMS.force_delete_instrument_site(resource_ids.instrument_siteb3_id)
        self.OMS.force_delete_instrument_site(resource_ids.instrument_site4_id)

    #@unittest.skip('targeting')
    def test_observatory_management(self):
        resources = self._make_associations()

        self._do_test_find_related_sites(resources)

        self._do_test_get_sites_devices_status(resources)

        self._do_test_find_site_data_products(resources)

        self._do_test_find_related_frames_of_reference(resources)

        self._do_test_create_geospatial_point_center(resources)

        self._do_test_find_observatory_org(resources)

        self.destroy(resources)

    def _do_test_find_related_sites(self, resources):

        site_resources, site_children = self.OMS.find_related_sites(resources.org_id)

        #import sys, pprint
        #print >> sys.stderr, pprint.pformat(site_resources)
        #print >> sys.stderr, pprint.pformat(site_children)

        #self.assertIn(resources.org_id, site_resources)
        self.assertIn(resources.observatory_id, site_resources)
        self.assertIn(resources.subsite_id, site_resources)
        self.assertIn(resources.subsite_id, site_resources)
        self.assertIn(resources.subsite2_id, site_resources)
        self.assertIn(resources.platform_site_id, site_resources)
        self.assertIn(resources.instrument_site_id, site_resources)
        self.assertEquals(len(site_resources), 13)

        self.assertEquals(site_resources[resources.observatory_id].type_, RT.Observatory)

        self.assertIn(resources.org_id, site_children)
        self.assertIn(resources.observatory_id, site_children)
        self.assertIn(resources.subsite_id, site_children)
        self.assertIn(resources.subsite_id, site_children)
        self.assertIn(resources.subsite2_id, site_children)
        self.assertIn(resources.platform_site_id, site_children)
        self.assertNotIn(resources.instrument_site_id, site_children)
        self.assertEquals(len(site_children), 9)

        self.assertIsInstance(site_children[resources.subsite_id], list)
        self.assertEquals(len(site_children[resources.subsite_id]), 2)

    def _do_test_get_sites_devices_status(self, resources):

        result_dict = self.OMS.get_sites_devices_status(resources.org_id)

        site_resources = result_dict.get("site_resources", None)
        site_children = result_dict.get("site_children", None)

#.........这里部分代码省略.........
开发者ID:shenrie,项目名称:coi-services,代码行数:101,代码来源:test_observatory_management_service_integration.py

示例13: TestObservatoryManagementServiceIntegration

class TestObservatoryManagementServiceIntegration(IonIntegrationTestCase):

    def setUp(self):
        # Start container
        #print 'instantiating container'
        self._start_container()
        #container = Container()
        #print 'starting container'
        #container.start()
        #print 'started container'

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')
        self.RR = ResourceRegistryServiceClient(node=self.container.node)
        self.OMS = ObservatoryManagementServiceClient(node=self.container.node)
        self.org_management_service = OrgManagementServiceClient(node=self.container.node)
        self.IMS =  InstrumentManagementServiceClient(node=self.container.node)
        self.dpclient = DataProductManagementServiceClient(node=self.container.node)
        self.pubsubcli =  PubsubManagementServiceClient(node=self.container.node)
        self.damsclient = DataAcquisitionManagementServiceClient(node=self.container.node)
        self.dataset_management = DatasetManagementServiceClient()
        #print 'TestObservatoryManagementServiceIntegration: started services'

        self.event_publisher = EventPublisher()

#    @unittest.skip('this exists only for debugging the launch process')
#    def test_just_the_setup(self):
#        return


    def destroy(self, resource_ids):
        self.OMS.force_delete_observatory(resource_ids.observatory_id)
        self.OMS.force_delete_subsite(resource_ids.subsite_id)
        self.OMS.force_delete_subsite(resource_ids.subsite2_id)
        self.OMS.force_delete_subsite(resource_ids.subsiteb_id)
        self.OMS.force_delete_subsite(resource_ids.subsitez_id)
        self.OMS.force_delete_platform_site(resource_ids.platform_site_id)
        self.OMS.force_delete_platform_site(resource_ids.platform_siteb_id)
        self.OMS.force_delete_platform_site(resource_ids.platform_siteb2_id)
        self.OMS.force_delete_platform_site(resource_ids.platform_site3_id)
        self.OMS.force_delete_instrument_site(resource_ids.instrument_site_id)
        self.OMS.force_delete_instrument_site(resource_ids.instrument_site2_id)
        self.OMS.force_delete_instrument_site(resource_ids.instrument_siteb3_id)
        self.OMS.force_delete_instrument_site(resource_ids.instrument_site4_id)

    #@unittest.skip('targeting')
    def test_resources_associations(self):
        resources = self._make_associations()
        self.destroy(resources)

    #@unittest.skip('targeting')
    def test_find_related_frames_of_reference(self):
        # finding subordinates gives a dict of obj lists, convert objs to ids
        def idify(adict):
            ids = {}
            for k, v in adict.iteritems():
                ids[k] = []
                for obj in v:
                    ids[k].append(obj._id)

            return ids

        # a short version of the function we're testing, with id-ify
        def short(resource_id, output_types):
            ret = self.OMS.find_related_frames_of_reference(resource_id,
                                                            output_types)
            return idify(ret)
            
            
        #set up associations first
        stuff = self._make_associations()
        #basic traversal of tree from instrument to platform
        ids = short(stuff.instrument_site_id, [RT.PlatformSite])
        self.assertIn(RT.PlatformSite, ids)
        self.assertIn(stuff.platform_site_id, ids[RT.PlatformSite])
        self.assertIn(stuff.platform_siteb_id, ids[RT.PlatformSite])
        self.assertNotIn(stuff.platform_siteb2_id, ids[RT.PlatformSite])

        #since this is the first search, just make sure the input inst_id got stripped
        if RT.InstrumentSite in ids:
            self.assertNotIn(stuff.instrument_site_id, ids[RT.InstrumentSite])

        #basic traversal of tree from platform to instrument
        ids = short(stuff.platform_siteb_id, [RT.InstrumentSite])
        self.assertIn(RT.InstrumentSite, ids)
        self.assertIn(stuff.instrument_site_id, ids[RT.InstrumentSite])
        self.assertNotIn(stuff.instrument_site2_id, ids[RT.InstrumentSite])


        #full traversal of tree from observatory down to instrument
        ids = short(stuff.observatory_id, [RT.InstrumentSite])
        self.assertIn(RT.InstrumentSite, ids)
        self.assertIn(stuff.instrument_site_id, ids[RT.InstrumentSite])


        #full traversal of tree from instrument to observatory
        ids = short(stuff.instrument_site_id, [RT.Observatory])
        self.assertIn(RT.Observatory, ids)
        self.assertIn(stuff.observatory_id, ids[RT.Observatory])


#.........这里部分代码省略.........
开发者ID:blazetopher,项目名称:coi-services,代码行数:101,代码来源:test_observatory_management_service_integration.py

示例14: TestOrgManagementServiceInt

class TestOrgManagementServiceInt(IonIntegrationTestCase):

    def setUp(self):

        # Start container
        self._start_container()
        self.container.start_rel_from_url('res/deploy/r2coi.yml')

        self.org_management_service = OrgManagementServiceClient(node=self.container.node)


    def test_org_crud(self):

        with self.assertRaises(BadRequest) as br:
            self.org_management_service.create_org(IonObject("Org", {"name": "Test Facility"}))
        self.assertTrue("can only contain alphanumeric and underscore characters" in br.exception.message)

        org_obj = IonObject("Org", {"name": "TestFacility"})
        org_id = self.org_management_service.create_org(org_obj)
        self.assertNotEqual(org_id, None)

        org = None
        org = self.org_management_service.read_org(org_id)
        self.assertNotEqual(org, None)

        #Check that the roles got associated to them
        role_list = self.org_management_service.find_org_roles(org_id)
        self.assertEqual(len(role_list),2 )

        org.name = 'Updated_TestFacility'
        self.org_management_service.update_org(org)

        org = None
        org = self.org_management_service.read_org(org_id)
        self.assertNotEqual(org, None)
        self.assertEqual(org.name, 'Updated_TestFacility')

        self.org_management_service.delete_org(org_id)

        with self.assertRaises(NotFound) as cm:
            self.org_management_service.read_org(org_id)
        self.assertIn("does not exist", cm.exception.message)

        with self.assertRaises(NotFound) as cm:
            self.org_management_service.delete_org(org_id)
        self.assertIn("does not exist", cm.exception.message)


    def test_org_affiliation(self):

        root_org = None
        root_org = self.org_management_service.find_org()
        self.assertNotEqual(root_org, None)

        org_obj = IonObject("Org", {"name": "TestFacility"})
        org_id = self.org_management_service.create_org(org_obj)
        self.assertNotEqual(org_id, None)

        ret = self.org_management_service.affiliate_org(root_org._id, org_id)
        self.assertTrue(ret)

        ret = self.org_management_service.unaffiliate_org(root_org._id, org_id)
        self.assertTrue(ret)
开发者ID:dstuebe,项目名称:coi-services,代码行数:63,代码来源:test_org_management_service.py

示例15: instrument_test_driver

def instrument_test_driver(container):

    org_client = OrgManagementServiceClient(node=container.node)
    id_client = IdentityManagementServiceClient(node=container.node)

    system_actor = id_client.find_actor_identity_by_name(name=CFG.system.system_actor)
    log.info("system actor:" + system_actor._id)

    sa_header_roles = get_role_message_headers(org_client.find_all_roles_by_user(system_actor._id))

    # Names of agent data streams to be configured.
    parsed_stream_name = "ctd_parsed"
    raw_stream_name = "ctd_raw"

    # Driver configuration.
    # Simulator

    driver_config = {
        "svr_addr": "localhost",
        "cmd_port": 5556,
        "evt_port": 5557,
        "dvr_mod": "ion.services.mi.drivers.sbe37_driver",
        "dvr_cls": "SBE37Driver",
        "comms_config": {
            SBE37Channel.CTD: {
                "method": "ethernet",
                "device_addr": CFG.device.sbe37.host,
                "device_port": CFG.device.sbe37.port,
                "server_addr": "localhost",
                "server_port": 8888,
            }
        },
    }

    # Hardware

    _container_client = ContainerAgentClient(node=container.node, name=container.name)

    # Create a pubsub client to create streams.
    _pubsub_client = PubsubManagementServiceClient(node=container.node)

    # A callback for processing subscribed-to data.
    def consume(message, headers):
        log.info("Subscriber received message: %s", str(message))

    # Create a stream subscriber registrar to create subscribers.
    subscriber_registrar = StreamSubscriberRegistrar(process=container, node=container.node)

    subs = []

    # Create streams for each stream named in driver.
    stream_config = {}
    for (stream_name, val) in PACKET_CONFIG.iteritems():
        stream_def = ctd_stream_definition(stream_id=None)
        stream_def_id = _pubsub_client.create_stream_definition(container=stream_def)
        stream_id = _pubsub_client.create_stream(
            name=stream_name,
            stream_definition_id=stream_def_id,
            original=True,
            encoding="ION R2",
            headers={"ion-actor-id": system_actor._id, "ion-actor-roles": sa_header_roles},
        )
        stream_config[stream_name] = stream_id

        # Create subscriptions for each stream.
        exchange_name = "%s_queue" % stream_name
        sub = subscriber_registrar.create_subscriber(exchange_name=exchange_name, callback=consume)
        sub.start()
        query = StreamQuery(stream_ids=[stream_id])
        sub_id = _pubsub_client.create_subscription(query=query, exchange_name=exchange_name)
        _pubsub_client.activate_subscription(sub_id)
        subs.append(sub)

    # Create agent config.

    agent_resource_id = "123xyz"

    agent_config = {
        "driver_config": driver_config,
        "stream_config": stream_config,
        "agent": {"resource_id": agent_resource_id},
    }

    # Launch an instrument agent process.
    _ia_name = "agent007"
    _ia_mod = "ion.services.mi.instrument_agent"
    _ia_class = "InstrumentAgent"
    _ia_pid = _container_client.spawn_process(name=_ia_name, module=_ia_mod, cls=_ia_class, config=agent_config)

    log.info("got pid=%s for resource_id=%s" % (str(_ia_pid), str(agent_resource_id)))
开发者ID:seman,项目名称:coi-services,代码行数:90,代码来源:instrument_driver.py


注:本文中的interface.services.coi.iorg_management_service.OrgManagementServiceClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。