Exemplo n.º 1
0
    def test_view(self):
        """Test the displaying of the category view"""
        self.clear_db()
        self.register_and_login('barney', 'abc')
        category = Category('drdre')
        db.session.add(category)
        db.session.commit()
        post = Post('the chronic', visible=True)
        post2 = Post('the chrinoc', visible=False)
        post._categories = [category]
        post2._categories = [category]
        db.session.add(post)
        db.session.add(post2)
        db.session.commit()
        rv = self.client.get('/category/drdre/')
        self.assert_200(rv)
        assert 'the chronic' in rv.data
        rv = self.client.get('/category/sugeknight/')
        self.assert_404(rv)

        self.logout()
        rv = self.client.get('/category/drdre/')
        self.assert_200(rv)
        assert 'the chronic' in rv.data
        assert 'the chrinoc' not in rv.data

        rv = self.client.get('/uncategorized/')
        self.assert_200(rv)
        assert 'Uncategorized posts' in rv.data
        post2 = Post('dancing in the moonlight')
        db.session.add(post2)
        db.session.commit()
        rv = self.client.get('/uncategorized/')
        self.assert_200(rv)
        assert 'dancing in the moonlight' in rv.data
Exemplo n.º 2
0
 def test_view(self):
     """Test the displaying of the category view"""
     self.clear_db()
     self.register_and_login('barney', 'abc')
     category = Category('drdre')
     db.session.add(category)
     db.session.commit()
     post = Post('the chronic', visible=True)
     post2 = Post('the chrinoc', visible=False)
     post._categories = [category]
     post2._categories = [category]
     db.session.add(post)
     db.session.add(post2)
     db.session.commit()
     rv = self.client.get('/category/drdre/')
     self.assert_200(rv)
     assert 'the chronic' in rv.data
     rv = self.client.get('/category/sugeknight/')
     self.assert_404(rv)
     
     self.logout()
     rv = self.client.get('/category/drdre/')
     self.assert_200(rv)
     assert 'the chronic' in rv.data
     assert 'the chrinoc' not in rv.data
     
     rv = self.client.get('/uncategorized/')
     self.assert_200(rv)
     assert 'Uncategorized posts' in rv.data
     post2 = Post('dancing in the moonlight')
     db.session.add(post2)
     db.session.commit()
     rv = self.client.get('/uncategorized/')
     self.assert_200(rv)
     assert 'dancing in the moonlight' in rv.data