• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python data_utils.rand_int_id函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_is_public_string_variations

    def test_is_public_string_variations(self):
        flavor_id_not_public = rand_int_id(start=1000)
        flavor_name_not_public = rand_name(self.flavor_name_prefix)
        flavor_id_public = rand_int_id(start=1000)
        flavor_name_public = rand_name(self.flavor_name_prefix)

        # Create a non public flavor
        resp, flavor = self.client.create_flavor(
            flavor_name_not_public, self.ram, self.vcpus, self.disk, flavor_id_not_public, is_public="False"
        )
        self.addCleanup(self.flavor_clean_up, flavor["id"])

        # Create a public flavor
        resp, flavor = self.client.create_flavor(
            flavor_name_public, self.ram, self.vcpus, self.disk, flavor_id_public, is_public="True"
        )
        self.addCleanup(self.flavor_clean_up, flavor["id"])

        def _flavor_lookup(flavors, flavor_name):
            for flavor in flavors:
                if flavor["name"] == flavor_name:
                    return flavor
            return None

        def _test_string_variations(variations, flavor_name):
            for string in variations:
                params = {"is_public": string}
                r, flavors = self.client.list_flavors_with_detail(params)
                self.assertEqual(r.status, 200)
                flavor = _flavor_lookup(flavors, flavor_name)
                self.assertNotEqual(flavor, None)

        _test_string_variations(["f", "false", "no", "0"], flavor_name_not_public)

        _test_string_variations(["t", "true", "yes", "1"], flavor_name_public)
开发者ID:hanlind,项目名称:tempest,代码行数:35,代码来源:test_flavors.py


示例2: _get_unused_flavor_id

 def _get_unused_flavor_id(self):
     flavor_id = data_utils.rand_int_id(start=1000)
     while True:
         try:
             resp, body = self.flavors_client.get_flavor_details(flavor_id)
         except exceptions.NotFound:
             break
         flavor_id = data_utils.rand_int_id(start=1000)
     return flavor_id
开发者ID:armando-migliaccio,项目名称:tempest,代码行数:9,代码来源:test_servers.py


示例3: _get_unused_flavor_id

 def _get_unused_flavor_id(self):
     flavor_id = data_utils.rand_int_id(start=1000)
     while True:
         try:
             self.flavors_client.show_flavor(flavor_id)
         except lib_exc.NotFound:
             break
         flavor_id = data_utils.rand_int_id(start=1000)
     return flavor_id
开发者ID:nunogt,项目名称:tempest,代码行数:9,代码来源:test_servers_negative.py


示例4: populate_smoke_table

 def populate_smoke_table(self, table_name, keycount, count_per_key):
     new_items = []
     for _ in range(keycount):
         forum = 'forum%s' % data_utils.rand_int_id()
         for i in range(count_per_key):
             item = self.build_smoke_item(forum,
                                          'subject%s' % i,
                                          data_utils.rand_name(),
                                          data_utils.rand_uuid(),
                                          str(data_utils.rand_int_id()))
             self.client.put_item(table_name, item)
             new_items.append(item)
     return new_items
开发者ID:sirmax123,项目名称:magnetodb,代码行数:13,代码来源:base.py


示例5: test_create_flavor_verify_entry_in_list_details

    def test_create_flavor_verify_entry_in_list_details(self):
        # Create a flavor and ensure it's details are listed
        # This operation requires the user to have 'admin' role
        flavor_name = data_utils.rand_name(self.flavor_name_prefix)
        new_flavor_id = data_utils.rand_int_id(start=1000)

        # Create the flavor
        flavor = self.client.create_flavor(
            name=flavor_name,
            ram=self.ram,
            vcpus=self.vcpus,
            disk=self.disk,
            id=new_flavor_id,
            ephemeral=self.ephemeral,
            swap=self.swap,
            rxtx_factor=self.rxtx,
        )["flavor"]
        self.addCleanup(self.flavor_clean_up, flavor["id"])
        flag = False
        # Verify flavor is retrieved
        flavors = self.client.list_flavors(detail=True)["flavors"]
        for flavor in flavors:
            if flavor["name"] == flavor_name:
                flag = True
        self.assertTrue(flag)
开发者ID:mshalamov,项目名称:tempest,代码行数:25,代码来源:test_flavors.py


示例6: _post_and_claim_messages

    def _post_and_claim_messages(self, queue_name, repeat=1):
        # Post Messages
        message_body = self.generate_message_body(repeat=repeat)
        self.client.post_messages(queue_name=self.queue_name,
                                  rbody=message_body)

        # Post Claim
        claim_ttl = data_utils.rand_int_id(start=60,
                                           end=CONF.queuing.max_claim_ttl)
        claim_grace = data_utils.rand_int_id(start=60,
                                             end=CONF.queuing.max_claim_grace)
        claim_body = {"ttl": claim_ttl, "grace": claim_grace}
        resp, body = self.client.post_claims(queue_name=self.queue_name,
                                             rbody=claim_body)

        return resp, body
开发者ID:BhargavaRegalla,项目名称:tempest,代码行数:16,代码来源:test_claims.py


示例7: setUpClass

    def setUpClass(cls):
        super(FlavorsExtraSpecsNegativeTestJSON, cls).setUpClass()
        if not test.is_extension_enabled('FlavorExtraData', 'compute'):
            msg = "FlavorExtraData extension not enabled."
            raise cls.skipException(msg)

        cls.client = cls.os_adm.flavors_client
        flavor_name = data_utils.rand_name('test_flavor')
        ram = 512
        vcpus = 1
        disk = 10
        ephemeral = 10
        cls.new_flavor_id = data_utils.rand_int_id(start=1000)
        swap = 1024
        rxtx = 1
        # Create a flavor
        resp, cls.flavor = cls.client.create_flavor(
            flavor_name,
            ram,
            vcpus,
            disk,
            cls.new_flavor_id,
            ephemeral=ephemeral,
            swap=swap,
            rxtx=rxtx)
开发者ID:JasGit,项目名称:tempest,代码行数:25,代码来源:test_flavors_extra_specs_negative.py


示例8: test_create_flavor_verify_entry_in_list_details

    def test_create_flavor_verify_entry_in_list_details(self):
        # Create a flavor and ensure it's details are listed
        # This operation requires the user to have 'admin' role
        flavor_name = rand_name(self.flavor_name_prefix)
        new_flavor_id = rand_int_id(start=1000)

        # Create the flavor
        resp, flavor = self.client.create_flavor(
            flavor_name,
            self.ram,
            self.vcpus,
            self.disk,
            new_flavor_id,
            ephemeral=self.ephemeral,
            swap=self.swap,
            rxtx=self.rxtx,
        )
        self.addCleanup(self.flavor_clean_up, flavor["id"])
        flag = False
        # Verify flavor is retrieved
        resp, flavors = self.client.list_flavors_with_detail()
        self.assertEqual(resp.status, 200)
        for flavor in flavors:
            if flavor["name"] == flavor_name:
                flag = True
        self.assertTrue(flag)
开发者ID:hanlind,项目名称:tempest,代码行数:26,代码来源:test_flavors.py


示例9: test_list_public_flavor_with_other_user

    def test_list_public_flavor_with_other_user(self):
        # Create a Flavor with public access.
        # Try to List/Get flavor with another user
        flavor_name = rand_name(self.flavor_name_prefix)
        new_flavor_id = rand_int_id(start=1000)

        try:
            # Create the flavor
            resp, flavor = self.client.create_flavor(
                flavor_name, self.ram, self.vcpus, self.disk, new_flavor_id, is_public="True"
            )
            flag = False
            self.new_client = self.flavors_client
            # Verify flavor is retrieved with new user
            resp, flavors = self.new_client.list_flavors_with_detail()
            self.assertEqual(resp.status, 200)
            for flavor in flavors:
                if flavor["name"] == flavor_name:
                    flag = True
            self.assertTrue(flag)
        finally:
            # Delete the flavor
            resp, body = self.client.delete_flavor(new_flavor_id)
            self.assertEqual(resp.status, 202)
            self.client.wait_for_resource_deletion(new_flavor_id)
开发者ID:dani4571,项目名称:tempest,代码行数:25,代码来源:test_flavors.py


示例10: test_create_flavor_verify_entry_in_list_details

    def test_create_flavor_verify_entry_in_list_details(self):
        # Create a flavor and ensure it's details are listed
        # This operation requires the user to have 'admin' role
        flavor_name = rand_name(self.flavor_name_prefix)
        new_flavor_id = rand_int_id(start=1000)

        try:
            #Create the flavor
            resp, flavor = self.client.create_flavor(flavor_name,
                                                     self.ram, self.vcpus,
                                                     self.disk,
                                                     new_flavor_id,
                                                     ephemeral=self.ephemeral,
                                                     swap=self.swap,
                                                     rxtx=self.rxtx)
            flag = False
            #Verify flavor is retrieved
            resp, flavors = self.client.list_flavors_with_detail()
            self.assertEqual(resp.status, 200)
            for flavor in flavors:
                if flavor['name'] == flavor_name:
                    flag = True
            self.assertTrue(flag)

        finally:
            #Delete the flavor
            resp, body = self.client.delete_flavor(new_flavor_id)
            self.assertEqual(resp.status, 202)
            self.client.wait_for_resource_deletion(new_flavor_id)
开发者ID:rushiagr,项目名称:tempest,代码行数:29,代码来源:test_flavors.py


示例11: test_volume_list_details_by_name

 def test_volume_list_details_by_name(self):
     volume = self.volume_list[data_utils.rand_int_id(0, 2)]
     params = {self.name: volume[self.name]}
     _, fetched_vol = self.client.list_volumes_with_detail(params)
     self.assertEqual(1, len(fetched_vol), str(fetched_vol))
     self.assertEqual(fetched_vol[0][self.name],
                      volume[self.name])
开发者ID:armando-migliaccio,项目名称:tempest-1,代码行数:7,代码来源:test_volumes_list.py


示例12: test_volume_list_by_name

 def test_volume_list_by_name(self):
     volume = self.volume_list[data_utils.rand_int_id(0, 2)]
     params = {self.name: volume[self.name]}
     fetched_vol = self.client.list_volumes(params=params)['volumes']
     self.assertEqual(1, len(fetched_vol), str(fetched_vol))
     self.assertEqual(fetched_vol[0][self.name],
                      volume[self.name])
开发者ID:Tesora,项目名称:tesora-tempest,代码行数:7,代码来源:test_volumes_list.py


示例13: test_flavor_access_add_remove

    def test_flavor_access_add_remove(self):
        # Test to add and remove flavor access to a given tenant.
        flavor_name = data_utils.rand_name(self.flavor_name_prefix)
        new_flavor_id = data_utils.rand_int_id(start=1000)
        resp, new_flavor = self.client.create_flavor(flavor_name,
                                                     self.ram, self.vcpus,
                                                     self.disk,
                                                     new_flavor_id,
                                                     is_public='False')
        self.addCleanup(self.client.delete_flavor, new_flavor['id'])
        # Add flavor access to a tenant.
        resp_body = {
            "tenant_id": str(self.tenant_id),
            "flavor_id": str(new_flavor['id']),
        }
        add_resp, add_body = \
            self.client.add_flavor_access(new_flavor['id'], self.tenant_id)
        self.assertEqual(add_resp.status, 200)
        self.assertIn(resp_body, add_body)

        # The flavor is present in list.
        resp, flavors = self.flavors_client.list_flavors_with_detail()
        self.assertEqual(resp.status, 200)
        self.assertIn(new_flavor['id'], map(lambda x: x['id'], flavors))

        # Remove flavor access from a tenant.
        remove_resp, remove_body = \
            self.client.remove_flavor_access(new_flavor['id'], self.tenant_id)
        self.assertEqual(remove_resp.status, 200)
        self.assertNotIn(resp_body, remove_body)

        # The flavor is not present in list.
        resp, flavors = self.flavors_client.list_flavors_with_detail()
        self.assertEqual(resp.status, 200)
        self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
开发者ID:Grindizer,项目名称:tempest,代码行数:35,代码来源:test_flavors_access.py


示例14: test_get_flavor_details_for_deleted_flavor

    def test_get_flavor_details_for_deleted_flavor(self):
        # Delete a flavor and ensure it is not listed
        # Create a test flavor
        flavor_name = rand_name(self.flavor_name_prefix)
        new_flavor_id = rand_int_id(start=1000)

        resp, flavor = self.client.create_flavor(flavor_name,
                                                 self.ram,
                                                 self.vcpus, self.disk,
                                                 new_flavor_id,
                                                 ephemeral=self.ephemeral,
                                                 swap=self.swap,
                                                 rxtx=self.rxtx)
        # Delete the flavor
        new_flavor_id = flavor['id']
        resp_delete, body = self.client.delete_flavor(new_flavor_id)
        self.assertEquals(200, resp.status)
        self.assertEquals(202, resp_delete.status)

        # Deleted flavors can be seen via detailed GET
        resp, flavor = self.client.get_flavor_details(new_flavor_id)
        self.assertEqual(resp.status, 200)
        self.assertEqual(flavor['name'], flavor_name)

        # Deleted flavors should not show up in a list however
        resp, flavors = self.client.list_flavors_with_detail()
        self.assertEqual(resp.status, 200)
        flag = True
        for flavor in flavors:
            if flavor['name'] == flavor_name:
                flag = False
        self.assertTrue(flag)
开发者ID:nateben,项目名称:tempest,代码行数:32,代码来源:test_flavors.py


示例15: test_list_non_public_flavor

    def test_list_non_public_flavor(self):
        # Create a flavor with os-flavor-access:is_public false should
        # be present in list_details.
        # This operation requires the user to have 'admin' role
        flavor_name = data_utils.rand_name(self.flavor_name_prefix)
        new_flavor_id = data_utils.rand_int_id(start=1000)

        # Create the flavor
        resp, flavor = self.client.create_flavor(flavor_name,
                                                 self.ram, self.vcpus,
                                                 self.disk,
                                                 new_flavor_id,
                                                 is_public="False")
        self.addCleanup(self.flavor_clean_up, flavor['id'])
        # Verify flavor is retrieved
        flag = False
        resp, flavors = self.client.list_flavors_with_detail()
        self.assertEqual(resp.status, 200)
        for flavor in flavors:
            if flavor['name'] == flavor_name:
                flag = True
        self.assertTrue(flag)

        # Verify flavor is not retrieved with other user
        flag = False
        resp, flavors = self.user_client.list_flavors_with_detail()
        self.assertEqual(resp.status, 200)
        for flavor in flavors:
            if flavor['name'] == flavor_name:
                flag = True
        self.assertFalse(flag)
开发者ID:andrewsben,项目名称:tempest,代码行数:31,代码来源:test_flavors.py


示例16: test_volume_list_details_by_name

 def test_volume_list_details_by_name(self):
     volume = self.volume_list[data_utils.rand_int_id(0, 2)]
     params = {'name': volume['name']}
     resp, fetched_vol = self.client.list_volumes_with_detail(params)
     self.assertEqual(200, resp.status)
     self.assertEqual(1, len(fetched_vol), str(fetched_vol))
     self.assertEqual(fetched_vol[0]['name'], volume['name'])
开发者ID:mrda,项目名称:tempest,代码行数:7,代码来源:test_volumes_list.py


示例17: test_create_flavor

    def test_create_flavor(self):
        # Create a flavor and ensure it is listed
        # This operation requires the user to have 'admin' role
        flavor_name = rand_name(self.flavor_name_prefix)
        new_flavor_id = rand_int_id(start=1000)

        # Create the flavor
        resp, flavor = self.client.create_flavor(flavor_name,
                                                 self.ram, self.vcpus,
                                                 self.disk,
                                                 new_flavor_id,
                                                 ephemeral=self.ephemeral,
                                                 swap=self.swap,
                                                 rxtx=self.rxtx)
        self.addCleanup(self.flavor_clean_up, flavor['id'])
        self.assertEqual(200, resp.status)
        self.assertEqual(flavor['name'], flavor_name)
        self.assertEqual(flavor['vcpus'], self.vcpus)
        self.assertEqual(flavor['disk'], self.disk)
        self.assertEqual(flavor['ram'], self.ram)
        self.assertEqual(int(flavor['id']), new_flavor_id)
        self.assertEqual(flavor['swap'], self.swap)
        self.assertEqual(flavor['rxtx_factor'], self.rxtx)
        self.assertEqual(flavor['OS-FLV-EXT-DATA:ephemeral'],
                         self.ephemeral)
        self.assertEqual(flavor['os-flavor-access:is_public'], True)

        # Verify flavor is retrieved
        resp, flavor = self.client.get_flavor_details(new_flavor_id)
        self.assertEqual(resp.status, 200)
        self.assertEqual(flavor['name'], flavor_name)
开发者ID:rossella,项目名称:tempest,代码行数:31,代码来源:test_flavors.py


示例18: test_volume_list_with_detail_param_display_name_and_status

 def test_volume_list_with_detail_param_display_name_and_status(self):
     # Test to list volume when name and status param is given
     volume = self.volume_list[data_utils.rand_int_id(0, 2)]
     params = {'name': volume['name'],
               'status': 'available'}
     self._list_by_param_value_and_assert(params, expected_list=[volume],
                                          with_detail=True)
开发者ID:mrda,项目名称:tempest,代码行数:7,代码来源:test_volumes_list.py


示例19: test_delete_security_group_rule_with_non_existent_id

 def test_delete_security_group_rule_with_non_existent_id(self):
     # Negative test: Deletion of Security Group rule should be FAIL
     # with non existent id
     non_existent_rule_id = data_utils.rand_int_id(start=999)
     self.assertRaises(exceptions.NotFound,
                       self.client.delete_security_group_rule,
                       non_existent_rule_id)
开发者ID:ironbits,项目名称:tempest,代码行数:7,代码来源:test_security_group_rules_negative.py


示例20: test_flavor_access_add_remove

    def test_flavor_access_add_remove(self):
        # Test to add and remove flavor access to a given tenant.
        flavor_name = data_utils.rand_name(self.flavor_name_prefix)
        new_flavor_id = data_utils.rand_int_id(start=1000)
        new_flavor = self.client.create_flavor(name=flavor_name,
                                               ram=self.ram, vcpus=self.vcpus,
                                               disk=self.disk,
                                               id=new_flavor_id,
                                               is_public='False')['flavor']
        self.addCleanup(self.client.delete_flavor, new_flavor['id'])
        # Add flavor access to a tenant.
        resp_body = {
            "tenant_id": str(self.tenant_id),
            "flavor_id": str(new_flavor['id']),
        }
        add_body = (self.client.add_flavor_access(new_flavor['id'],
                                                  self.tenant_id)
                    ['flavor_access'])
        self.assertIn(resp_body, add_body)

        # The flavor is present in list.
        flavors = self.flavors_client.list_flavors(detail=True)['flavors']
        self.assertIn(new_flavor['id'], map(lambda x: x['id'], flavors))

        # Remove flavor access from a tenant.
        remove_body = (self.client.remove_flavor_access(new_flavor['id'],
                                                        self.tenant_id)
                       ['flavor_access'])
        self.assertNotIn(resp_body, remove_body)

        # The flavor is not present in list.
        flavors = self.flavors_client.list_flavors(detail=True)['flavors']
        self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
开发者ID:flyingfish007,项目名称:tempest,代码行数:33,代码来源:test_flavors_access.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python data_utils.rand_mac_address函数代码示例发布时间:2022-05-27
下一篇:
Python data_utils.parse_image_id函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap