def test_creation(self):
        """Test the blog post's fields' correctness after adding an 
        post and test proper category association"""
        self.clear_db()
        self.register_and_login('barney', 'abc')
        
        title = "My post"
        markup = "# Title"
        tags = "django, franz und bertha,vil/bil"
        category1_id = self.add_category('cool')
        category2_id = self.add_category('cooler')
        self.add_post(title=title, markup=markup, tags=tags,
            categories=[category1_id, category1_id, category2_id])
            
        post = Post.query.get(1)
        post_tagnames = [tag.name for tag in post.tags]
        category_names = [x.name for x in post.categories]
        
        assert_equal(post.id, 1)
        assert_equal(post.title, title)
        assert_equal(post.markup, markup)
        assert_false(post.comments_allowed)
        assert_false(post.visible)
        assert_equal(post.slug, 'my-post')
        assert '<h1>Title</h1>' in post.html
        assert_equal(post.datetime.date(), datetime.date.today())
        assert_equal(sorted(post_tagnames), 
            sorted(['django','franz-und-bertha','vil-bil']))
        assert_equal(sorted(category_names), sorted(['cool', 'cooler']))
        
        assert_equal(Tag.query.count(), 3)
        assert_equal(Category.query.count(), 2)
        assert_equal(db.session.query(post_tags).count(), 3)
        # Expect only two mappings although the mapping to category1
        # has been added twice  
        assert_equal(db.session.query(post_categories).count(), 2)
        
        # Add another post
        self.add_post(title=post.title, tags=['django'], comments_allowed=True,
            visible=True)
        post2 = Post.query.get(2)
        
        assert_equal(post2.title, post.title) 
        assert_true(post2.comments_allowed)
        assert_true(post2.visible)
        assert_equal(post2.slug, post.slug % '-2')
        assert_equal(post2.categories, [])
        assert_equal(Tag.query.count(), 3)
        
        return post
dataset/ETHPy150Open eugenkiss/Simblin/test/test_views.py/TestPost.test_creation/operator `+` -> `%`