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)
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)
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'])
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)