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


Python Film.production_country_list方法代码示例

本文整理汇总了Python中film20.core.models.Film.production_country_list方法的典型用法代码示例。如果您正苦于以下问题:Python Film.production_country_list方法的具体用法?Python Film.production_country_list怎么用?Python Film.production_country_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在film20.core.models.Film的用法示例。


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

示例1: setUp

# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import production_country_list [as 别名]
    def setUp(self):
        User.objects.all().delete()
        Film.objects.all().delete()
        Rating.objects.all().delete()
        ShortReview.objects.all().delete()

        #create sample user
        user1 = User.objects.create_user('michuk',
                                       '[email protected]',
                                       'secret')
        user1.save()
        user2 = User.objects.create_user('john',
                                       '[email protected]',
                                       'secret')
        user2.save()

        tags = "science-fiction comedy"

        #create sample user rating
        film1 = Film()
        film1.title = "Battlefield Earth II"
        film1.type = Object.TYPE_FILM
        film1.permalink = "battlefirld-earth-ii"
        film1.release_year = 2010
        film1.production_country_list = "USA"
        film1.save()
        film1.save_tags(tags, LANG="pl", saved_by=2)

        film2 = Film()
        film2.title = "Battlefield Earth III"
        film2.type = Object.TYPE_FILM
        film2.permalink = "battlefirld-earth-iii"
        film2.release_year = 2011
        film2.production_country_list = "USA"
        film2.save()
        film2.save_tags(tags, LANG="pl", saved_by=2)

        film3 = Film()
        film3.title = "Battlefield Earth IV"
        film3.type = Object.TYPE_FILM
        film3.permalink = "battlefirld-earth-iv"
        film3.release_year = 2012
        film3.production_country_list = "Italy"
        film3.save()
        film3.save_tags(tags, LANG="pl", saved_by=2)

        film4 = Film()
        film4.title = "Battlefield Earth V"
        film4.type = Object.TYPE_FILM
        film4.permalink = "battlefirld-earth-v"
        film4.release_year = 2013
        film4.production_country_list = "UK"
        film4.save()
        film4.save_tags(tags, LANG="pl", saved_by=2)

        
        # set up test user ratings
        save_rating(film1, user1, 1)
        save_rating(film2, user1, 3)
        save_rating(film3, user1, 4)
        save_rating(film4, user1, 6)

        save_rating(film2, user2, 2)
        save_rating(film3, user2, 3)
        save_rating(film4, user2, 5)

        users = User.objects.all()
        self.assertEquals(len(users), 2)

        films = Film.objects.all()
        self.assertEquals(len(films), 4)

        user1 = users[0].id
        ratings1 = Rating.objects.filter(Q(user=user1))
        self.assertEquals(len(ratings1), 4)

        user2 = users[1].id
        ratings2 = Rating.objects.filter(Q(user=user2))
        self.assertEquals(len(ratings2), 3)

        reviews1 = ShortReview.objects.filter(Q(user=user1))
        self.assertEquals(len(reviews1), 0)

        reviews2 = ShortReview.objects.filter(Q(user=user2))
        self.assertEquals(len(reviews2), 0)
开发者ID:thuvh,项目名称:filmmaster,代码行数:87,代码来源:test_download.py


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