Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
 def test_create_post(self):
     PermissionSystem(self.env).grant_permission('user', 'BLOG_VIEW')
     core = FullBlogCore(self.env)
     req = Mock(method='GET', base_path='', cgi_location='',
                path_info='/blog', href=Href('/trac'), args={}, chrome={},
                perm=PermissionCache(self.env, 'user'), authname='user')
     bp = BlogPost(self.env, 'about')
     bp.update_fields(fields={'title': 'test_create_post', 'author': 'user',
         'body': 'First body'})
     warnings = core.create_post(req, bp, req.authname)
     self.assertEquals(warnings, [])
     posts = get_blog_posts(self.env)
     self.assertEquals(1, len(posts))
     self.assertEquals('test_create_post', posts[0][4])
Exemplo n.º 3
0
 def test_create_post(self):
     PermissionSystem(self.env).grant_permission('user', 'BLOG_VIEW')
     core = FullBlogCore(self.env)
     req = MockRequest(self.env,
                       method='GET',
                       path_info='/blog',
                       authname='user')
     bp = BlogPost(self.env, 'about')
     bp.update_fields(fields={
         'title': 'test_create_post',
         'author': 'user',
         'body': 'First body'
     })
     warnings = core.create_post(req, bp, req.authname)
     self.assertEquals(warnings, [])
     posts = get_blog_posts(self.env)
     self.assertEquals(1, len(posts))
     self.assertEquals('test_create_post', posts[0][4])
Exemplo n.º 4
0
    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)