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


Python Film.get_title方法代码示例

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


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

示例1: PostTestCase

# 需要导入模块: from film20.core.models import Film [as 别名]
# 或者: from film20.core.models.Film import get_title [as 别名]

#.........这里部分代码省略.........

        post2 = Post()
        post2.title = "third post"
        post2.permalink = "third-post"
        post2.body = "post third post"
        post2.user = self.u1
        post2.status = Post.PUBLIC_STATUS
        post2.type = Post.TYPE_POST
        post2.featured_note = True
        post2.save()

        post = Post.objects.featured_review()
        self.assertEqual(post.permalink, u'third-post')

        # change featured post status and check if cache is invalidated
        post2 = Post.objects.get(title__iexact='third post')
        post2.status = Post.DRAFT_STATUS
        post2.save()

        post = Post.objects.featured_review()
        self.assertEqual(post.permalink, u'second-post')

        # republished post
        post2 = Post.objects.get(title__iexact='third post')
        post2.status = Post.PUBLIC_STATUS
        post2.save()

        post = Post.objects.featured_review()
        self.assertEqual(post.permalink, u'third-post')
        self.assertEqual(Post.objects.recent_reviews().count(), 0)

    def test_tagging( self ):
        """
            test posts tagging
        """

        post = Post()
        post.title = "Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u1
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.tag_list = 'ww2,pl,lorem'
        post.save()

        self.assertEqual( UserActivity.objects.all_notes().tagged( 'ww2' ).count(), 1 )

    def test_related_movies( self ):
        """
            test post related movies
        """

        self.assertEqual( Post.objects.count(), 0 )

        params = { 
            "title"       : "Battlefield review",
            "body"        : "Lorem ipsum",
            "publish"     : "1",
            "related_film": "Battlefield Earth II [2010],"
        }
        
        self.client.login( username='michuk', password='secret' )
        response = self.client.post( reverse( 'new_article' ), params, follow=True )
        
        self.assertEqual( response.status_code, 200 )
        self.assertEqual( Post.objects.count(), 1 )

        post = Post.objects.all()[0]

        self.assertEqual( post.title, params['title'] )
        self.assertEqual( post.related_film.count(), 1 )
        
        self.assertEqual( UserActivity.objects.count(), 1 )

        act = UserActivity.objects.all()[0]

        self.assertFalse( act.film is None )
        self.assertEqual( act.film_title, self.film.get_title() )
        self.assertEqual( act.film_permalink, self.film.permalink )


        # edit article
        params['related_film'] = ''
        response = self.client.post( reverse( 'edit_article', args=[post.pk] ), params, follow=True )
        
        self.assertEqual( response.status_code, 200 )
        self.assertEqual( Post.objects.count(), 1 )

        post = Post.objects.all()[0]

        self.assertEqual( post.related_film.count(), 0 )
        
        self.assertEqual( UserActivity.objects.count(), 1 )

        act = UserActivity.objects.all()[0]

        self.assertTrue( act.film is None  )
        self.assertTrue( act.film_title is None  )
        self.assertTrue( act.film_permalink is None  )
开发者ID:thuvh,项目名称:filmmaster,代码行数:104,代码来源:post_tests.py


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