本文整理汇总了Python中factory.fuzzy.FuzzyText方法的典型用法代码示例。如果您正苦于以下问题:Python fuzzy.FuzzyText方法的具体用法?Python fuzzy.FuzzyText怎么用?Python fuzzy.FuzzyText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factory.fuzzy
的用法示例。
在下文中一共展示了fuzzy.FuzzyText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_user_registration
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_user_registration(self):
"""Ensure that user registration works properly."""
EMAIL = Faker("email").generate()
PASSWORD = fuzzy.FuzzyText(length=16)
test_user_data = {
"password1": PASSWORD,
"password2": PASSWORD,
"email": EMAIL,
"email2": EMAIL,
}
# Verify that POSTing user data to the registration view
# succeeds / returns the right HTTP status code.
response = self.client.post(
reverse("account_signup"), test_user_data)
# Successful form submission will cause the HTTP status code
# to be "302 Found", not "200 OK".
self.assertEqual(response.status_code, 302)
# Verify that a User has been successfully created.
user_model = get_user_model()
user_model.objects.get(email=EMAIL)
示例2: create
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def create(self, validated_data):
request = self.context.get("request")
if request and request.user:
validated_data["user"] = request.user
if "identicon_seed" not in validated_data:
validated_data["identicon_seed"] = f"v1:{FuzzyText().fuzz()}"
recipe = Recipe.objects.create()
return self.update(recipe, validated_data)
示例3: test_is_physical_after_filling_barcode_whithout_removing_file
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_is_physical_after_filling_barcode_whithout_removing_file():
specimen = DigitalBookSpecimenFactory(
barcode=FuzzyText(length=6))
assert not specimen.physical
示例4: setUp
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def setUp(self):
super(AccountsTestCase, self).setUp()
self.password = fuzzy.FuzzyText(length=16)
self.new_password = fuzzy.FuzzyText(length=16)
user_model = get_user_model()
self.user = user_model.objects.get_or_create(
username="test",
email="example@example.com",
first_name="Test",
last_name="User",
)[0]
self.user.set_password(self.password)
self.user.save()
示例5: setUp
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def setUp(self):
super(MarketingSiteAPIClientTestMixin, self).setUp()
self.username = FuzzyText().fuzz()
self.password = FuzzyText().fuzz()
self.api_root = FuzzyUrlRoot().fuzz()
self.csrf_token = FuzzyText().fuzz()
self.user_id = FuzzyInteger(1).fuzz()
示例6: fuzz
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def fuzz(self):
subdomain = FuzzyText()
domain = FuzzyText()
tld = FuzzyChoice(('com', 'net', 'org', 'biz', 'pizza', 'coffee', 'diamonds', 'fail', 'win', 'wtf',))
return "{subdomain}.{domain}.{tld}".format(
subdomain=subdomain.fuzz().lower(),
domain=domain.fuzz().lower(),
tld=tld.fuzz()
)
示例7: test_expired_voucher
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_expired_voucher(self):
""" Verify proper response is returned for expired vouchers. """
code = FuzzyText().fuzz().upper()
start_datetime = now() - datetime.timedelta(days=20)
end_datetime = now() - datetime.timedelta(days=10)
prepare_voucher(code=code, start_datetime=start_datetime, end_datetime=end_datetime)
url = format_url(path=self.path, params={'code': code})
response = self.client.get(url)
self.assertEqual(response.context['error'], 'This coupon code has expired.')
示例8: test_no_product
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_no_product(self):
""" Verify an error is returned for voucher with no product. """
code = FuzzyText().fuzz().upper()
no_product_range = RangeFactory()
prepare_voucher(code=code, _range=no_product_range)
url = format_url(path=self.path, params={'code': code})
response = self.client.get(url)
self.assertEqual(response.context['error'], 'The voucher is not applicable to your current basket.')
示例9: test_invalid_voucher_code
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_invalid_voucher_code(self):
""" Verify an error is returned when voucher does not exist. """
code = FuzzyText().fuzz().upper()
url = format_url(base=self.redeem_url, params={'code': code, 'sku': self.stock_record.partner_sku})
response = self.client.get(url)
msg = 'No voucher found with code {code}'.format(code=code)
self.assertEqual(response.context['error'], msg)
示例10: test_get_non_existing_voucher
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_get_non_existing_voucher(self):
""" Verify that get_voucher_and_products_from_code() raises exception for a non-existing voucher. """
with self.assertRaises(Voucher.DoesNotExist):
get_voucher_and_products_from_code(code=FuzzyText().fuzz())
示例11: raw_content
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def raw_content(self):
parts = []
for tag in ["tagone", "tagtwo", "tagthree", "tagthree", "SnakeCase", "UPPER", ""]:
parts.append(fuzzy.FuzzyText(length=50).fuzz())
parts.append("#%s" % tag)
shuffle(parts)
return " ".join(parts)
示例12: test_index_context_anonymous
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_index_context_anonymous(self):
"""
Assert context values when anonymous
"""
ga_tracking_id = FuzzyText().fuzz()
with self.settings(
GA_TRACKING_ID=ga_tracking_id,
), patch('ui.templatetags.render_bundle._get_bundle') as get_bundle:
response = self.client.get('/')
bundles = [bundle[0][1] for bundle in get_bundle.call_args_list]
assert set(bundles) == {
'public',
'sentry_client',
'style',
'style_public',
'zendesk_widget',
}
assert response.context['authenticated'] is False
assert response.context['username'] is None
assert response.context['title'] == HomePage.objects.first().title
assert response.context['is_public'] is True
assert response.context['has_zendesk_widget'] is True
assert response.context['is_staff'] is False
assert response.context['programs'] == []
self.assertContains(response, 'Share this page')
js_settings = json.loads(response.context['js_settings_json'])
assert js_settings['gaTrackingID'] == ga_tracking_id
示例13: test_index_context_logged_in_social_auth
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_index_context_logged_in_social_auth(self):
"""
Assert context values when logged in as social auth user
"""
profile = self.create_and_login_user()
user = profile.user
ga_tracking_id = FuzzyText().fuzz()
with self.settings(
GA_TRACKING_ID=ga_tracking_id,
), patch('ui.templatetags.render_bundle._get_bundle') as get_bundle:
response = self.client.get('/')
bundles = [bundle[0][1] for bundle in get_bundle.call_args_list]
assert set(bundles) == {
'public',
'sentry_client',
'style',
'style_public',
'zendesk_widget',
}
assert response.context['authenticated'] is True
assert response.context['username'] == get_social_username(user)
assert response.context['title'] == HomePage.objects.first().title
assert response.context['is_public'] is True
assert response.context['has_zendesk_widget'] is True
assert response.context['is_staff'] is False
assert response.context['programs'] == []
self.assertContains(response, 'Share this page')
js_settings = json.loads(response.context['js_settings_json'])
assert js_settings['gaTrackingID'] == ga_tracking_id
示例14: test_index_context_logged_in_no_social_auth
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_index_context_logged_in_no_social_auth(self):
"""
Assert context values when logged in without a social_auth account
"""
with mute_signals(post_save):
profile = ProfileFactory.create()
self.client.force_login(profile.user)
ga_tracking_id = FuzzyText().fuzz()
with self.settings(
GA_TRACKING_ID=ga_tracking_id,
), patch('ui.templatetags.render_bundle._get_bundle') as get_bundle:
response = self.client.get('/')
bundles = [bundle[0][1] for bundle in get_bundle.call_args_list]
assert set(bundles) == {
'public',
'sentry_client',
'style',
'style_public',
'zendesk_widget',
}
assert response.context['authenticated'] is True
assert response.context['username'] is None
assert response.context['title'] == HomePage.objects.first().title
assert response.context['is_public'] is True
assert response.context['has_zendesk_widget'] is True
assert response.context['is_staff'] is False
assert response.context['programs'] == []
self.assertContains(response, 'Share this page')
js_settings = json.loads(response.context['js_settings_json'])
assert js_settings['gaTrackingID'] == ga_tracking_id
示例15: test_index_context_logged_in_staff
# 需要导入模块: from factory import fuzzy [as 别名]
# 或者: from factory.fuzzy import FuzzyText [as 别名]
def test_index_context_logged_in_staff(self, role):
"""
Assert context values when logged in as staff for a program
"""
program = ProgramFactory.create(live=True)
with mute_signals(post_save):
profile = ProfileFactory.create()
Role.objects.create(
role=role,
program=program,
user=profile.user,
)
self.client.force_login(profile.user)
ga_tracking_id = FuzzyText().fuzz()
with self.settings(
GA_TRACKING_ID=ga_tracking_id,
):
response = self.client.get('/')
assert response.context['authenticated'] is True
assert response.context['username'] is None
assert response.context['title'] == HomePage.objects.first().title
assert response.context['is_public'] is True
assert response.context['has_zendesk_widget'] is True
assert response.context['is_staff'] is True
assert response.context['programs'] == [
(program, None),
]
self.assertContains(response, 'Share this page')
js_settings = json.loads(response.context['js_settings_json'])
assert js_settings['gaTrackingID'] == ga_tracking_id