Esempio n. 1
0
    def test_fetchAll(self):
        self.storage.save(BlogData(subject='blog1',content='This is blog1'))
        self.storage.save(BlogData(subject='blog2',content='This is blog2'))
        expected = 2
        actual = self.storage.fetchAll()
        print actual
        self.assertEquals(expected, actual.count(), "Blog count of " + str(expected) + ' size was not found.')

        pass
 def post(self):
     '''
     Handles blog entry creation
     '''
     self.response.headers['Content-Type'] = 'text/html'
     isValid = True
     values = {}
     subject = self.request.get('subject')
     if not subject:
         values['subject_error'] = 'Blog subject is required'
         isValid = False
     content = self.request.get('content')
     if not content:
         values['content_error'] = 'Blog content is required'
         isValid = False
     path = None
     if not isValid:
         values['subject'] = subject
         values['content'] = content
         path = os.path.join(os.path.dirname(__file__),
                             'create_blog_entry.html')
     else:
         blog = BlogData(subject=subject, content=content)
         service = BlogService(BlogDataStoreFactory())
         service.save(blog)
         blog_entries = service.fetchAll()
         values['blog_entries'] = blog_entries
         path = os.path.join(os.path.dirname(__file__), 'blog.html')
     self.response.out.write(template.render(path, values))
Esempio n. 3
0
 def test_fetch(self):
     b = BlogData(subject='blog1',content='This is blog1')
     expected = b.subject 
     self.storage.save(b)
     b1 = self.storage.fetch(1)
     self.assertEquals(expected, b1.subject, "Blog with id " + str(expected) + ' was not found.')
     pass
    def fetch(self, entry_id):
        #        blog_entry = None
        #        sql = "select * from BlogData where entry_id=" + entry_id
        blog_entry = BlogData.get_by_id(entry_id)
        #        blog_entries = db.GqlQuery(sql)
        #        for entry in blog_entries:
        #            blog_entry = entry

        return blog_entry
    def fetch(self, entry_id):
#        blog_entry = None
#        sql = "select * from BlogData where entry_id=" + entry_id
        blog_entry = BlogData.get_by_id(entry_id)
#        blog_entries = db.GqlQuery(sql)
#        for entry in blog_entries:
#            blog_entry = entry

        return blog_entry
Esempio n. 6
0
 def test_save(self):
     b3 = BlogData(subject='blog1',content='This is blog1')
     self.storage.save(b3)
     b3a = self.storage.fetch(1)
     self.assertEquals(b3.content, b3a.content, "Blog " + str(b3) + ' was not saved. This was saved instead: ' + str(b3a))
     pass
Esempio n. 7
0
 def testPut(self):
     data = BlogData(subject='Foo',content='Foo blog')
     data.put()
     pass