コード例 #1
0
    def test_create_json(self):
        url = 'Test Subject'
        content = 'Test Content'
        wiki = WikiData(url=url,content=content)
        wiki.put()
        wiki_id = wiki.key().id()
#        wiki_data = self.service.fetch(wiki_id)
        json_string = self.service.create_json(wiki_id)
        self.assertTrue(('"url": "%s"' % url) in json_string, "Actual json string: " + str(json_string))
        self.assertTrue(('"content": "%s"' % content) in json_string, "Actual json string: " + str(json_string))
コード例 #2
0
    def test_create_json_with_double_quotes(self):
        url = 'Test"s Subject'
        content = 'Test"s Content'
        wiki = WikiData(url=url,content=content)
        wiki.put()
        wiki_id = wiki.key().id()
#        wiki_data = self.service.fetch(wiki_id)
        json_string = self.service.create_json(wiki_id)
        quote = url.find('"')
        json_url = url[0:quote] + '\\' + url[quote:]
        quote = content.find('"')
        json_content = content[0:quote] + '\\' + content[quote:]
        self.assertTrue(('"url": "%s"' % json_url) in json_string, "Actual json string: " + str(json_string))
        self.assertTrue(('"content": "%s"' % json_content) in json_string, "Actual json string: " + str(json_string))
コード例 #3
0
    def test_fetch_cacheTest(self):
        b1 = WikiData(url='blog1', content='This is blog1')
        self.storage.save(b1)
        b2 = WikiData(url='blog2', content='This is blog2')
        self.storage.save(b2)
        b3 = WikiData(url='blog1', content='This is blog2')
        self.storage.save(b3)
        b4 = WikiData(url='blog1', content='This is blog1')
        self.storage.save(b4)
        b5 = WikiData(url='blog1', content='This is blog1')
        self.storage.save(b5)
        b6 = WikiData(url='blog1', content='This is blog1')
        self.storage.save(b6)
        b5_id = b5.key().id()

        actual1 = self.storage.fetch(b5_id)

        cache_key = str(b5_id) + DATA_CACHE_KEY_SUFFIX
        actual2 = memcache.get(cache_key)

        self.assertEquals(actual1.content, actual2.content)
    def test_fetch_cacheTest(self):
        b1 = WikiData(url='blog1',content='This is blog1')
        self.storage.save(b1)
        b2 = WikiData(url='blog2',content='This is blog2')
        self.storage.save(b2)
        b3 = WikiData(url='blog1',content='This is blog2')
        self.storage.save(b3)
        b4 = WikiData(url='blog1',content='This is blog1')
        self.storage.save(b4)
        b5 = WikiData(url='blog1',content='This is blog1')
        self.storage.save(b5)
        b6 = WikiData(url='blog1',content='This is blog1')
        self.storage.save(b6)
        b5_id = b5.key().id()

        actual1 = self.storage.fetch(b5_id)
        
        cache_key = str(b5_id) + DATA_CACHE_KEY_SUFFIX 
        actual2 = memcache.get(cache_key)

        self.assertEquals(actual1.content, actual2.content)