def METHOD_NAME(post_factory, tag_factory):
    post = post_factory()
    tag1 = tag_factory()
    tag2 = tag_factory()
    db.session.add_all([tag1, tag2, post])
    db.session.flush()
    post.tags.append(tag1)
    post.tags.append(tag2)
    db.session.commit()
    assert len(post.tags) == 2
    assert post.tag_count == 2
    db.session.delete(tag1)
    db.session.commit()
    db.session.refresh(post)
    assert len(post.tags) == 1
    assert post.tag_count == 1
    db.session.delete(tag2)
    db.session.commit()
    db.session.refresh(post)
    assert len(post.tags) == 0
    assert post.tag_count == 0