def test_count_unpublished(self): executeRaw( "INSERT INTO pages (content, created_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000','slug-2', 'Another Title')" ) count = self.service.count_unpublished() self.assertEqual(count, 1)
def test_get_unpublished(self): executeRaw( "INSERT INTO pages (content, created_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000','slug-2', 'UnPublished Title')" ) pages = self.service.get_unpublished(0, 1) page = pages[0] self.assertEqual(len(pages), 1) self.assertEqual(page.title, "UnPublished Title")
def setUp(self): createSchema() executeRaw( "INSERT INTO pages (content, created_at, published_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000','2012-09-10 19:20:01.410000','slug', 'Page Title')" ) self.service = page_service
def setUp(self): self.service = search_service db = web.database(dbn='sqlite', db=web.config.dbpath) executeRaw("CREATE VIRTUAL TABLE search using FTS4(title, slug, content, published_at,ispost);") executeRaw("INSERT INTO SEARCH(title,slug, content, published_at, isPost) VALUES ('Hello World','Hello World', 'hello world this is my first post','2010-10-03 11:15:52.000000', '1')") executeRaw("INSERT INTO SEARCH(title,slug, content, published_at, isPost) VALUES ('Hi World','Hi World', 'hello world this is my second post','2010-10-04 11:15:52.000000','1')") executeRaw("INSERT INTO SEARCH(title,slug, content, published_at, isPost) VALUES('Hello World','Hello World', 'Sup world this is another post','2010-10-05 11:15:52.000000','1')") executeRaw("INSERT INTO SEARCH(title,slug, content, published_at, isPost) VALUES('o World', 'o World', 'namste world this is my first post','2010-10-06 11:15:52.000000','1')")
def test_get_all(self): executeRaw("INSERT INTO posts (content, created_at, excerpt, published_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000', 'test excerpt', '2012-08-10 19:20:01.410000', 'slug-2', 'Another Title')") posts = self.service.get_all(0, 2) self.assertEqual(len(posts), 2) posts = self.service.get_all(0, 3) self.assertEqual(len(posts), 2) posts = self.service.get_all(0, 1) self.assertEqual(len(posts), 1) post = self.service.get_all(1, 2)[0] self.assertIsInstance(post, Post, "obj is not an instance of Post") self.assertEqual(post.title, "Another Title")
def setUp(self): createSchema() executeRaw("INSERT INTO archives (year,month,posts_count) VALUES (2012,9,1)") executeRaw("INSERT INTO posts (content, created_at, excerpt, published_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000', 'test excerpt', '2012-09-10 19:20:01.410000', 'slug', 'Post Title')") executeRaw("INSERT INTO tags (slug, title,posts_count) VALUES ('slug', 'Post Title',1)") executeRaw("INSERT INTO taggings (post_id, tag_id) VALUES (1,1)") self.service = post_service
def test_get_unpublished(self): executeRaw("INSERT INTO posts (content, created_at, excerpt, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000', 'test excerpt', 'slug', 'UnPublished Title')") executeRaw("INSERT INTO tags (slug, title,posts_count) VALUES ('tag-slug', 'Un Published Tag Title',1)") executeRaw("INSERT INTO taggings (post_id, tag_id) VALUES (2,2)") tags = self.service.get_unpublished() self.assertEqual(len(tags), 1) self.assertEqual(tags[0].title, "Un Published Tag Title")
def test_post_update(self): executeRaw("INSERT INTO archives (year,month,posts_count) VALUES (2012,9,1)") executeRaw("INSERT INTO posts (content, created_at, excerpt, published_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000', 'test excerpt', '2012-09-10 19:20:01.410000', 'slug', 'Post Title')") executeRaw("INSERT INTO tags (slug, title,posts_count) VALUES ('slug', 'tag',1)") executeRaw("INSERT INTO taggings (post_id, tag_id) VALUES (1,1)") t = datetime.now() post = self.service.update(1, "updated title", "updated-title", "<p>updated-content</p>", t, "updated-excerpt", ["tag3"]) self.assertEqual(post.title, "updated title") self.assertEqual(post.slug, "updated-title") self.assertEqual(post.content, "<p>updated-content</p>") self.assertEqual(post.published_at, t) self.assertEqual(post.excerpt, "updated-excerpt") self.assertEqual(len(post.tags), 1) self.assertEqual(post.tags[0].title, "tag3") row = list(executeRaw("select * from taggings"))[0] self.assertEqual(row.post_id, 1) self.assertEqual(row.tag_id, 2) tags = list(executeRaw("select * from tags")) self.assertEqual(tags[0].title, "tag") self.assertEqual(tags[1].title, "tag3")
def test_get_all_published(self): executeRaw( "INSERT INTO pages (content, created_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000','slug-2', 'Another Title')" ) pages = self.service.get_all_published() self.assertEqual(len(pages), 1)
def test_destroy(self): executeRaw( "INSERT INTO pages (content, created_at, published_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000','2012-09-10 19:20:01.410000','slug', 'Page Title')" ) self.service.destroy(1) self.assertEqual(self.service.count_all(), 0)
def test_count_all(self): executeRaw("INSERT INTO posts (content, created_at, excerpt, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000', 'test excerpt', 'slug-2', 'Another Title')") executeRaw("INSERT INTO posts (content, created_at, excerpt, published_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000', 'test excerpt', '2012-08-10 19:20:01.410000', 'slug-2', 'Another Title')") count = self.service.count_all() self.assertEqual(count, 3)
def test_import(self): self.service.import_blog("BlogML.xml") print list(executeRaw("select count(*) from posts"))[0]
def test_get_popular(self): executeRaw("INSERT INTO posts (content, created_at, excerpt, published_at, slug, title) VALUES ('test - 2', '2012-09-10 19:20:01.413000', 'test excerpt', '2012-09-10 19:20:01.410000', 'slug - 2', 'Post Title - 2')") executeRaw("INSERT INTO tags (slug, title,posts_count) VALUES ('tag-slug-2', 'Tag Title 2',1)") executeRaw("INSERT INTO taggings (post_id, tag_id) VALUES (2,2)") executeRaw("INSERT INTO posts (content, created_at, excerpt, published_at, slug, title) VALUES ('test - 2', '2012-09-10 19:20:01.413000', 'test excerpt', '2012-09-10 19:20:01.410000', 'slug - 3', 'Post Title - 3')") executeRaw("Update tags set posts_count = 2 where slug ='tag-slug-2'") executeRaw("INSERT INTO taggings (post_id, tag_id) VALUES (3,2)") tags = self.service.get_popular(2) tag = tags[0] self.assertEqual(tag.title, 'Tag Title 2') self.assertEqual(tag.slug, 'tag-slug-2')
def test_count_published(self): executeRaw("INSERT INTO posts (content, created_at, excerpt, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000', 'test excerpt', 'slug-2', 'UnPublished Title')") executeRaw("INSERT INTO tags (slug, title,posts_count) VALUES ('tag-slug-2', 'Tag Title 2',1)") executeRaw("INSERT INTO taggings (post_id, tag_id) VALUES (2,2)") count = self.service.count_published() self.assertEqual(count, 1)
def setUp(self): createSchema() executeRaw("""INSERT INTO "settings"(blog_title , tag_line, meta_keywords, meta_description , items_per_page, posts_in_home, cache_duration_in_seconds , login, password, user_full_name, user_email, user_bio, user_short_name , root, google_analytics_code, feed_burner_url, bing_app_id, disqus_short_name, disqus_url) VALUES( 'Bhaguli Blog', 'Blog Engine', 'python', 'Blog Engine written in Python' ,10, 5, 10, 'admin', 'admin', 'Bhaguli', '*****@*****.**', 'author bio', 'author short', 'http://*****:*****@a.com', 'user_bio':'author bio', 'user_short_name':'author short' , 'root':'http://localhost:3333', 'google_analytics_code':'', 'feed_burner_url':'/', 'bing_app_id':'', 'disqus_short_name':'', 'disqus_url':''}
def test_find_recent(self): executeRaw("INSERT INTO posts (content, created_at, excerpt, published_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000', 'test excerpt', '2012-10-10 19:20:01.410000', 'slug-2', 'Recent Title')") post = self.service.find_recent(1)[0] self.assertEqual(post.title, "Recent Title")
def setUp(self): createSchema() executeRaw("INSERT INTO archives (year,month,posts_count) VALUES (2012,9,1)") executeRaw("""INSERT INTO posts (content, created_at, excerpt, published_at, slug, title) VALUES ('test', '2012-09-10 19:20:01.413000', 'test excerpt', '2012-09-10 19:20:01.410000', 'post-slug', 'Post Title')""") executeRaw("INSERT INTO tags (slug, title,posts_count) VALUES ('tag', 'tag',1)") executeRaw("INSERT INTO taggings (post_id, tag_id) VALUES (1,1)") executeRaw(""" INSERT INTO pages ( content,created_at,published_at,slug,title) VALUES ('test','2012-09-10 19:20:01.413000','2012-09-10 19:20:01.410000','page-slug','Page Title') """) executeRaw("INSERT INTO pages (content, created_at, published_at, slug, title) VALUES ('test page', '2012-09-10 19:20:01.413000','2012-09-10 19:20:01.410000','slug', 'Page Title')") executeRaw("""INSERT INTO "settings"(blog_title , tag_line, meta_keywords, meta_description , items_per_page, posts_in_home, cache_duration_in_seconds , login, password, user_full_name, user_email, user_bio, user_short_name , root, google_analytics_code, feed_burner_url, bing_app_id, disqus_short_name, disqus_url) VALUES( 'Bhaguli Blog',' Blog Engine',' python',' Blog Engine written in Python' ,10, 5, 10, 'admin', 'admin', 'Bhaguli', '*****@*****.**', 'author bio', 'author short', 'http://localhost:3333', '', '/', '', '', '' ) """) from services import metaweblog_service self.service = metaweblog_service
def tearDown(self): executeRaw("DROP TABLE search;")