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


Python OrgManagementServiceClient.read_org方法代码示例

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


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

示例1: TestOrgManagementServiceInt

# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import read_org [as 别名]
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,代码行数:60,代码来源:test_org_management_service.py

示例2: TestOrgManagementServiceInt

# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import read_org [as 别名]
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,代码行数:94,代码来源:test_org_management_service.py

示例3: TestOrgManagementServiceInt

# 需要导入模块: from interface.services.coi.iorg_management_service import OrgManagementServiceClient [as 别名]
# 或者: from interface.services.coi.iorg_management_service.OrgManagementServiceClient import read_org [as 别名]
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,代码行数:65,代码来源:test_org_management_service.py


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