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


Python Avatar.delete方法代码示例

本文整理汇总了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&nbsp;<span>&nbsp;<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()
开发者ID:michelesr,项目名称:coding-events,代码行数:58,代码来源:test_event_views.py


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