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


Python helpers.random_string函数代码示例

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


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

示例1: setUpClass

    def setUpClass(cls):
        default_user = helpers.default_user()

        cls.job = models.OqJob(owner=default_user)
        cls.job.save()

        # dmg dist per asset
        cls.ddpa_output = models.Output(
            owner=default_user, oq_job=cls.job,
            display_name='Test dmg dist per asset',
            output_type='dmg_dist_per_asset',
            db_backed=True)
        cls.ddpa_output.save()

        cls.ddpa = models.DmgDistPerAsset(
            output=cls.ddpa_output, dmg_states=cls.DMG_STATES)
        cls.ddpa.save()

        # We also need some sample exposure data records (to satisfy the dmg
        # dist per asset FK).
        test_input = models.Input(
            owner=default_user, input_type='exposure', path='fake', size=0)
        test_input.save()
        i2j = models.Input2job(input=test_input, oq_job=cls.job)
        i2j.save()
        exp_model = models.ExposureModel(
            owner=default_user, input=test_input, name='test-exp-model',
            category='economic loss', stco_type='per_asset', stco_unit='CHF')
        exp_model.save()

        test_site = shapes.Site(3.14, 2.17)
        cls.exp_data = models.ExposureData(  # Asset
            exposure_model=exp_model, asset_ref=helpers.random_string(),
            taxonomy=helpers.random_string(), number_of_units=37,
            site=test_site.point.to_wkt(), stco=1234.56)
        cls.exp_data.save()

        # dmg dist per taxonomy
        cls.ddpt_output = models.Output(
            owner=default_user, oq_job=cls.job,
            display_name='Test dmg dist per taxonomy',
            output_type='dmg_dist_per_taxonomy',
            db_backed=True)
        cls.ddpt_output.save()

        cls.ddpt = models.DmgDistPerTaxonomy(
            output=cls.ddpt_output, dmg_states=cls.DMG_STATES)
        cls.ddpt.save()

        # total dmg dist
        cls.ddt_output = models.Output(
            owner=default_user, oq_job=cls.job,
            display_name='Test dmg dist total',
            output_type='dmg_dist_total',
            db_backed=True)
        cls.ddt_output.save()

        cls.ddt = models.DmgDistTotal(
            output=cls.ddt_output, dmg_states=cls.DMG_STATES)
        cls.ddt.save()
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:60,代码来源:model_risk_dmg_dist_test.py

示例2: test_exposure_data_with_coco_and_unit_type_count

 def test_exposure_data_with_coco_and_unit_type_count(self):
     # the content cost may be present when unit_type is set to "count"
     site = shapes.Site(-122.5000, 37.5000)
     edata = models.ExposureData(
         exposure_model=self.mdl, asset_ref=helpers.random_string(),
         taxonomy=helpers.random_string(), number_of_units=111,
         site=site.point.to_wkt(), coco=112)
     edata.save()
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:8,代码来源:model_risk_exposure_test.py

示例3: test_exposure_data_unit_type_count

 def test_exposure_data_unit_type_count(self):
     # the unit_type is set to "count" and we can insert an `exposure_data`
     # row as long as we omit the area, reco and stco properties.
     site = shapes.Site(-122.5000, 37.5000)
     edata = models.ExposureData(
         exposure_model=self.mdl, asset_ref=helpers.random_string(),
         taxonomy=helpers.random_string(), number_of_units=111,
         site=site.point.to_wkt())
     edata.save()
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:9,代码来源:model_risk_exposure_test.py

示例4: test_exposure_data_with_no_stco_and_population

 def test_exposure_data_with_no_stco_and_population(self):
     # the structural cost needs not be present when we calculate exposure
     # in terms of population
     self.mdl.stco_type = None
     self.mdl.stco_unit = None
     self.mdl.category = "population"
     self.mdl.save()
     site = shapes.Site(-122.5000, 37.5000)
     edata = models.ExposureData(
         exposure_model=self.mdl, asset_ref=helpers.random_string(),
         taxonomy=helpers.random_string(), number_of_units=111,
         site=site.point.to_wkt())
     edata.save()
开发者ID:kpanic,项目名称:openquake,代码行数:13,代码来源:risk_exposure_model_unittest.py

示例5: test_exposure_data_with_coco_type_but_no_value

 def test_exposure_data_with_coco_type_but_no_value(self):
     # if the content cost type is set the value must be set as well.
     site = shapes.Site(-122.5000, 37.5000)
     edata = models.ExposureData(
         exposure_model=self.mdl, asset_ref=helpers.random_string(),
         taxonomy=helpers.random_string(), number_of_units=111,
         site=site.point.to_wkt())
     try:
         edata.save()
     except DatabaseError, de:
         self.assertEqual(
             "Exception: contents cost is mandatory for "
             "<coco_type=per_asset> (exposure_data)",
             de.args[0].split('\n', 1)[0])
         transaction.rollback()
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:15,代码来源:model_risk_exposure_test.py

示例6: test_exposure_data_with_area_and_unit_type_count

 def test_exposure_data_with_area_and_unit_type_count(self):
     # the area cost must not be present when unit_type is set to "count"
     site = shapes.Site(-122.5000, 37.5000)
     edata = models.ExposureData(
         exposure_model=self.mdl, asset_ref=helpers.random_string(),
         taxonomy=helpers.random_string(), number_of_units=111,
         site=site.point.to_wkt(), area=112)
     try:
         edata.save()
     except DatabaseError, de:
         self.assertEqual(
             "Exception: We are in counting mode: neither of these must "
             "be set ['area'] (exposure_data)",
             de.args[0].split('\n', 1)[0])
         transaction.rollback()
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:15,代码来源:model_risk_exposure_test.py

示例7: test_ddpt_insert_valid_dmg_state

 def test_ddpt_insert_valid_dmg_state(self):
     for ds in self.DMG_STATES:
         dd = models.DmgDistPerTaxonomyData(
             dmg_dist_per_taxonomy=self.ddpt,
             taxonomy=helpers.random_string(), dmg_state=ds, mean=0.0,
             stddev=0.0)
         dd.save()
开发者ID:wmorales,项目名称:oq-engine,代码行数:7,代码来源:model_risk_dmg_dist_unittest.py

示例8: setUpClass

    def setUpClass(cls):
        cls.job = engine.prepare_job()
        jp, _, _ = engine.import_job_profile(RISK_DEMO_CONFIG_FILE, cls.job)

        cls.job_ctxt = helpers.create_job({}, job_id=cls.job.id,
                                          oq_job_profile=jp, oq_job=cls.job)
        calc = ClassicalRiskCalculator(cls.job_ctxt)

        calc.store_exposure_assets()
        [input] = models.inputs4job(cls.job.id, input_type="exposure")
        model = input.model()
        assets = model.exposuredata_set.filter(taxonomy="af/ctc-D/LR")
        # Add some more assets.
        coos = [(10.000155392289116, 46.546194318563),
                (10.222034128255, 46.0071299176413),
                (10.520376165581, 46.247463385278)]
        for lat, lon in coos:
            site = shapes.Site(lat, lon)
            cls.sites.append(site)
            if assets:
                continue
            location = geos.GEOSGeometry(site.point.to_wkt())
            asset = models.ExposureData(
                exposure_model=model, taxonomy="af/ctc-D/LR",
                asset_ref=helpers.random_string(6), stco=lat * 2,
                site=location, reco=1.1 * lon)
            asset.save()
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:27,代码来源:general_test.py

示例9: test_ddpt_update_invalid_dmg_state

 def test_ddpt_update_invalid_dmg_state(self):
     dd = models.DmgDistPerTaxonomy(
         taxonomy=helpers.random_string(),
         dmg_state=self.dmg_states['extensive'], mean=0.0,
         stddev=0.0)
     dd.save()
     self._test_insert_update_invalid(dd, 'dmg_dist_per_taxonomy')
开发者ID:4x,项目名称:oq-engine,代码行数:7,代码来源:model_risk_dmg_dist_test.py

示例10: test_ddpt_insert_valid_dmg_state

 def test_ddpt_insert_valid_dmg_state(self):
     for ds in self.dmg_states.itervalues():
         dd = models.DmgDistPerTaxonomy(
             taxonomy=helpers.random_string(),
             dmg_state=ds, mean=0.0,
             stddev=0.0)
         dd.save()
开发者ID:4x,项目名称:oq-engine,代码行数:7,代码来源:model_risk_dmg_dist_test.py

示例11: test_exposure_data_with_no_stco_and_category_not_population

 def test_exposure_data_with_no_stco_and_category_not_population(self):
     # the structural cost must be present when we calculate exposure
     # in terms other than population.
     self.mdl.save()
     site = shapes.Site(-122.4000, 37.6000)
     edata = models.ExposureData(
         exposure_model=self.mdl, asset_ref=helpers.random_string(),
         taxonomy=helpers.random_string(), number_of_units=111,
         site=site.point.to_wkt())
     try:
         edata.save()
     except DatabaseError, de:
         self.assertEqual(
             "Exception: structural cost is mandatory for category "
             "<economic loss> (exposure_data)",
             de.args[0].split('\n', 1)[0])
         transaction.rollback()
开发者ID:kpanic,项目名称:openquake,代码行数:17,代码来源:risk_exposure_model_unittest.py

示例12: test_ddpt_update_valid_dmg_state

 def test_ddpt_update_valid_dmg_state(self):
     dd = models.DmgDistPerTaxonomy(
         taxonomy=helpers.random_string(),
         dmg_state=self.dmg_states['extensive'], mean=0.0,
         stddev=0.0)
     dd.save()
     dd.dmg_state = self.dmg_states['complete']
     dd.save()
开发者ID:4x,项目名称:oq-engine,代码行数:8,代码来源:model_risk_dmg_dist_test.py

示例13: test_del_haz_calc_no_access

    def test_del_haz_calc_no_access(self):
        # Test the case where we try to delete a hazard calculation which does
        # not belong to current user.
        # In this case, deletion is now allowed and should raise an exception.
        hazard_job = helpers.get_hazard_job(self.hazard_cfg,
                                            username=helpers.random_string())
        hazard_calc = hazard_job.hazard_calculation

        self.assertRaises(RuntimeError, engine.del_haz_calc, hazard_calc.id)
开发者ID:Chunghan,项目名称:oq-engine,代码行数:9,代码来源:engine_test.py

示例14: test_prepare_user_exists

    def test_prepare_user_exists(self):
        user_name = helpers.random_string()
        existing_user = models.OqUser(
            user_name=user_name, full_name=user_name, organization_id=1
        )
        existing_user.save()

        user = engine2.prepare_user(user_name)
        self.assertEqual(existing_user.id, user.id)
开发者ID:matley,项目名称:oq-engine,代码行数:9,代码来源:engine2_test.py

示例15: test_exposure_stco_type_but_no_stco_value

 def test_exposure_stco_type_but_no_stco_value(self):
     # the structural cost must be present if the structural cost type
     # is set.
     self.mdl.category = "population"
     self.mdl.save()
     site = shapes.Site(-121.6000, 38.4000)
     edata = models.ExposureData(
         exposure_model=self.mdl, asset_ref=helpers.random_string(),
         taxonomy=helpers.random_string(), number_of_units=24,
         site=site.point.to_wkt())
     try:
         edata.save()
     except DatabaseError, de:
         self.assertEqual(
             "Exception: structural cost is mandatory for "
             "<stco_type=aggregated> (exposure_data)",
             de.args[0].split('\n', 1)[0])
         transaction.rollback()
开发者ID:kpanic,项目名称:openquake,代码行数:18,代码来源:risk_exposure_model_unittest.py


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