本文整理汇总了Python中lib.utils.string_utils.StringMethods.random_string方法的典型用法代码示例。如果您正苦于以下问题:Python StringMethods.random_string方法的具体用法?Python StringMethods.random_string怎么用?Python StringMethods.random_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.utils.string_utils.StringMethods
的用法示例。
在下文中一共展示了StringMethods.random_string方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dashboard_gca
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import random_string [as 别名]
def test_dashboard_gca(self, new_control_rest, selenium):
# pylint: disable=anomalous-backslash-in-string
"""Check Dashboard Tab is exist if 'Dashboard' GCA filled
with right value. Possible values match to regexp r"^https?://[^\s]+$".
Steps:
- Create 'Dashboard' gcas for object.
- Fill with values
- Check if 'Dashboard' tab exist.
- Navigate to 'Dashboard' tab.
- Check only GCAs filled with right values displayed on the tab.
"""
urls = ["https://gmail.by/", "https://www.google.com/",
environment.app_url, StringMethods.random_string(),
"ftp://something.com/"]
cads_rest_service = rest_service.CustomAttributeDefinitionsService()
gca_defs = (cads_rest_service.create_dashboard_gcas(
new_control_rest.type, count=len(urls)))
control_rest_service = rest_service.ControlsService()
control_rest_service.update_obj(
obj=new_control_rest, custom_attributes=dict(
zip([gca_def.id for gca_def in gca_defs], urls)))
expected_dashboards_items = dict(zip(
[gca_def.title.replace(aliases.DASHBOARD + "_", "")
for gca_def in gca_defs], urls[:3]))
controls_ui_service = webui_service.ControlsService(selenium)
is_dashboard_tab_exist = (
controls_ui_service.is_dashboard_tab_exist(new_control_rest))
assert is_dashboard_tab_exist
actual_dashboards_items = (
controls_ui_service.get_items_from_dashboard_widget(new_control_rest))
assert expected_dashboards_items == actual_dashboards_items
cads_rest_service.delete_objs(gca_defs)
示例2: test_asmt_from_template_w_dropdown_url
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import random_string [as 别名]
def test_asmt_from_template_w_dropdown_url(
self, program, control_mapped_to_program, audit, selenium
):
"""Check evidence url could be filled in
via Assessment dropdown.
Objects structure:
Program.
-> Control mapped to program.
-> Audit.
-> Asmt template with evidence url dropdown.
-> Autogenerated asmt.
"""
asmt_template_w_dropdown = rest_facade.create_asmt_template_w_dropdown(
audit, ["url"])
expected_asmt = rest_facade.create_asmt_from_template_rest(
audit, control_mapped_to_program, asmt_template_w_dropdown)
dropdown = CustomAttributeDefinitionsFactory().create(
**expected_asmt.cads_from_template()[0])
asmt_service = webui_service.AssessmentsService(selenium)
exp_url = StringMethods.random_string(
size=StringMethods.RANDOM_STR_LENGTH)
expected_asmt = asmt_service.choose_and_fill_dropdown_lca(
expected_asmt, dropdown, url=exp_url)
expected_asmt_urls = [exp_url]
expected_asmt.update_attrs(
updated_at=self.info_service().get_obj(obj=expected_asmt).updated_at,
evidence_urls=expected_asmt_urls,
mapped_objects=[control_mapped_to_program.title],
status=object_states.IN_PROGRESS).repr_ui()
actual_asmt = asmt_service.get_obj_from_info_page(obj=expected_asmt)
self.general_equal_assert(expected_asmt, actual_asmt, "audit")
示例3: generate_string
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import random_string [as 别名]
def generate_string(cls, first_part,
allowed_chars=StringMethods.ALLOWED_CHARS):
"""Generate random string in unicode format according to object type.
Symbols allowed in random part may be specified by
`allowed_chars` argument.
"""
return unicode("{first_part}_{uuid}_{rand_str}".format(
first_part=first_part, uuid=StringMethods.random_uuid(),
rand_str=StringMethods.random_string(chars=allowed_chars)))