def test_single_post(self):
        PermissionSystem(self.env).grant_permission('user', 'BLOG_VIEW')
        bp = BlogPost(self.env, 'first_post')
        bp.update_fields(fields={
            'title': 'First Post',
            'author': 'user',
            'body': 'First body'
        })
        self.assertEquals([], bp.save('user'))
        req = Mock(method='GET',
                   base_path='',
                   cgi_location='',
                   path_info='/blog',
                   href=Href('/trac'),
                   args={},
                   chrome={},
                   perm=PermissionCache(self.env, 'user'),
                   authname='user')

        module = FullBlogModule(self.env)
        assert module.match_request(req)
        template, data, _ = module.process_request(req)

        self.assertEqual(1, data['blog_total'])
        self.assertEqual(1, len(data['blog_post_list']))
        self.assertEqual('First Post', data['blog_post_list'][0].title)
示例#2
0
文件: web_ui.py 项目: jier38/TracSite
    def test_rss_no_posts(self):
        PermissionSystem(self.env).grant_permission('user', 'BLOG_VIEW')
        req = MockRequest(self.env,
                          method='GET',
                          path_info='/blog',
                          authname='user',
                          args={'format': 'rss'})

        module = FullBlogModule(self.env)
        self.assertTrue(module.match_request(req))
        template, data, _ = module.process_request(req)

        self.assertEquals('fullblog.rss', template)
示例#3
0
文件: web_ui.py 项目: jier38/TracSite
    def test_no_posts(self):
        PermissionSystem(self.env).grant_permission('user', 'BLOG_VIEW')
        req = MockRequest(self.env,
                          method='GET',
                          path_info='/blog',
                          authname='user')

        module = FullBlogModule(self.env)
        self.assertTrue(module.match_request(req))
        template, data, _ = module.process_request(req)

        self.assertEquals('fullblog_view.html', template)
        self.assertEqual([], data['blog_post_list'])
    def test_rss_no_posts(self):
        PermissionSystem(self.env).grant_permission('user', 'BLOG_VIEW')
        req = Mock(method='GET',
                   base_path='',
                   cgi_location='',
                   path_info='/blog',
                   href=Href('/trac'),
                   abs_href=Href('http://domain/trac'),
                   args={'format': 'rss'},
                   chrome={},
                   perm=PermissionCache(self.env, 'user'),
                   authname='user')

        module = FullBlogModule(self.env)
        assert module.match_request(req)
        template, data, _ = module.process_request(req)

        self.assertEquals('fullblog.rss', template)
    def test_no_posts(self):
        PermissionSystem(self.env).grant_permission('user', 'BLOG_VIEW')
        req = Mock(method='GET',
                   base_path='',
                   cgi_location='',
                   path_info='/blog',
                   href=Href('/trac'),
                   args={},
                   chrome={},
                   perm=PermissionCache(self.env, 'user'),
                   authname='user')

        module = FullBlogModule(self.env)
        assert module.match_request(req)
        template, data, _ = module.process_request(req)

        self.assertEquals('fullblog_view.html', template)
        self.assertEqual([], data['blog_post_list'])
示例#6
0
文件: web_ui.py 项目: jier38/TracSite
    def test_single_post(self):
        PermissionSystem(self.env).grant_permission('user', 'BLOG_VIEW')
        bp = BlogPost(self.env, 'first_post')
        bp.update_fields(fields={
            'title': 'First Post',
            'author': 'user',
            'body': 'First body'
        })
        self.assertEquals([], bp.save('user'))
        req = MockRequest(self.env,
                          method='GET',
                          path_info='/blog',
                          authname='user')

        module = FullBlogModule(self.env)
        self.assertTrue(module.match_request(req))
        template, data, _ = module.process_request(req)

        self.assertEqual(1, data['blog_total'])
        self.assertEqual(1, len(data['blog_post_list']))
        self.assertEqual('First Post', data['blog_post_list'][0].title)