def test_modify_post_from_db(self): """Tests that a Post Object can be modified and recommited.""" self.add_post() post = Post.query.first() now = datetime.now() post.title = "Test Post" post.gfm_content = gfm("Test Content") post.created = now post.slug = slugify(post.title) tag = Tag("Test Tag") post.tags = [tag] cat = Category("Test Category") post.category = cat user = User("Test User") post.author = user self.add_post(post) post = Post.query.first() self.assertEquals(post.title, "Test Post") self.assertEquals(post.gfm_content, gfm("Test Content")) self.assertEquals(post.created, now) self.assertEquals(post.tags, [tag]) self.assertEquals(post.slug, slugify(post.title)) self.assertEquals(post.category, cat) self.assertEquals(post.author, user) self.remove_post(post)
def test_modify_cat_from_db(self): """Tests that a Category Object can be modified and recommited.""" self.add_cat() cat = Category.query.first() cat.title = "Test Category" cat.slug = slugify(cat.title) self.add_cat(cat) cat = Category.query.first() self.assertEquals(cat.title, "Test Category") self.assertEquals(cat.slug, slugify(cat.title)) self.remove_cat(cat)
def test_create_cat_with_ctor(self): """Tests the constructor for the Category Model.""" cat = Category("Test Category") self.add_cat(cat) cat = Category.query.first() self.assertEquals(cat.title, "Test Category") self.assertEquals(cat.slug, slugify(cat.title)) self.remove_cat(cat)
def test_default_post_values(self): """Tests that the values for a default Post are as expected.""" now = datetime.now() self.add_post() post = Post.query.first() later = datetime.now() self.assertEquals(post.title, '') self.assertEquals(post.gfm_content, gfm('')) self.assertEquals(post.slug, slugify(post.title)) self.assertIsNone(post.author) self.assertIsNone(post.category) self.assertEquals(post.tags, []) self.assertGreaterEqual(post.created, now) self.assertLessEqual(post.created, later) self.remove_post(post)
def test_create_post_with_ctor(self): """Tests the constructor for the Post Model.""" now = datetime.now() tag = Tag("Test Tag") category = Category("Test Category") user = User("Test User") post = Post("Test Post", "## Test H2", now, [tag], None, category, user) self.add_post(post) post = Post.query.first() self.assertEquals(post.title, "Test Post") self.assertEquals(post.gfm_content, gfm("## Test H2")) self.assertEquals(post.created, now) self.assertEquals(post.tags, [tag]) self.assertEquals(post.slug, slugify(post.title)) self.assertEquals(post.category, category) self.assertEquals(post.author, user) self.remove_post(post)
def test_cat_slugify(self): """Tests that slugification works as expected.""" cat = Category("Test Category") self.assertEquals(cat.slug, slugify(cat.title))
def test_unicode_repr(self): """Tests that Post.__unicode__ representation is as expected.""" post = Post("Test Post") self.assertEquals(post.__unicode__(), slugify(post.title))