本文整理汇总了Python中avatar.models.Avatar.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Avatar.delete方法的具体用法?Python Avatar.delete怎么用?Python Avatar.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类avatar.models.Avatar
的用法示例。
在下文中一共展示了Avatar.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ambassadors_list
# 需要导入模块: from avatar.models import Avatar [as 别名]
# 或者: from avatar.models.Avatar import delete [as 别名]
def test_ambassadors_list(db, client):
test_country_name = "Austria"
test_country_code = "AT"
test_username = "test-amb"
test_email = "[email protected]"
test_first_name = "Testko"
test_last_name = "Test"
test_full_name = test_first_name + " " + test_last_name
test_ambassador = User.objects.create(
username=test_username, email=test_email, first_name=test_first_name, last_name=test_last_name
)
test_ambassador_profile = UserProfile.objects.create(user=test_ambassador, country=test_country_code)
group = Group.objects.get(name="ambassadors")
group.user_set.add(test_ambassador)
with open(local(__file__).dirname + "/../../static/img/team/alja.jpg") as fp:
io = StringIO.StringIO()
io.write(fp.read())
uploaded_picture = InMemoryUploadedFile(io, None, "alja17.jpg", "jpeg", io.len, None)
uploaded_picture.seek(0)
avatar = Avatar(user=test_ambassador, primary=True)
avatar.avatar.save(uploaded_picture.name, uploaded_picture)
avatar.save()
new_avatar = get_primary_avatar(test_ambassador, size=80)
test_amb_avatar = new_avatar.avatar_url(80)
response = client.get(reverse("web.ambassadors"))
# We're expecting to the Ambassador under the right country,
# with the right avatar and the right email contact
expected_result = """
<h2 class="clearfix">%s</h2>
<div class="ambassador clearfix">
<img src="%s" alt="%s" width="80" height="80" class="img-circle" />
<h4>%s <span> <a alt="Send me an email" href="mailto:%s"><i class="fa fa-envelope"></i></a>
""" % (
test_country_name,
test_amb_avatar,
test_username,
test_full_name,
test_email,
)
expected_result = expected_result.replace("\t", "").replace("\n", "")
ambassadors_content = response.content.replace("\t", "").replace("\n", "")
# Check this test and modify it to integrating the Ambassadors page changes
# assert expected_result in ambassadors_content
test_ambassador.delete()
avatar.delete()