def test_BlogToJson_with_double_quote(self): blog = BlogData(subject="Test1", content='Test1 blog"s content') self.storage.save(blog) blog_id = blog.key().id() stored_blog = self.storage.fetch(blog_id) actual = JsonUtils.blog_to_json(stored_blog); self.assertTrue('"subject": "Test1"' in actual,"Blog subject not parsed correctly in blog data: " + repr(actual)) self.assertTrue('"content": "Test1 blog\\"s content"' in actual,"Blog content not parsed correctly in blog data: " + repr(actual))
def test_BlogListToJson(self): blog1 = BlogData(subject="Test1", content='Test1 blog content') self.storage.save(blog1) blog2 = BlogData(subject="Test2", content='Test2 blog content') self.storage.save(blog2) blog_list = self.storage.fetchAll() actual = JsonUtils.blog_list_to_json(blog_list) print actual print str(len(actual)) self.assertFalse(len(actual) == 0)
def test_BlogListToJson(self): blog1 = BlogData(subject="Test1", content='Test1 blog content') self.storage.save(blog1) blog2 = BlogData(subject="Test2", content='Test2 blog content') self.storage.save(blog2) blog_list = self.storage.fetchAll() actual = JsonUtils.blog_list_to_json(blog_list); print actual print str(len(actual)) self.assertFalse(len(actual) == 0)
def test_BlogToJson_with_double_quote(self): blog = BlogData(subject="Test1", content='Test1 blog"s content') self.storage.save(blog) blog_id = blog.key().id() stored_blog = self.storage.fetch(blog_id) actual = JsonUtils.blog_to_json(stored_blog) self.assertTrue( '"subject": "Test1"' in actual, "Blog subject not parsed correctly in blog data: " + repr(actual)) self.assertTrue( '"content": "Test1 blog\\"s content"' in actual, "Blog content not parsed correctly in blog data: " + repr(actual))
def create_all_json(self): blog_list = self.fetchAll() return JsonUtils.blog_list_to_json(blog_list)
def create_json(self, blog_id): blog = self.fetch(blog_id) blog_json = JsonUtils.blog_to_json(blog) return blog_json