コード例 #1
0
ファイル: all_tests.py プロジェクト: jangxyz/ecogwiki
def suite():
  suite = unittest.TestSuite()
  suite.addTests(memory_test.suite())
  try:
    test_utils.init_appengine()
    import memcache_test
    suite.addTests(memcache_test.suite())
    import datastore_test
    suite.addTests(datastore_test.suite())
    import layered_test
    suite.addTests(layered_test.suite())
    try:
      test_utils.init_httplib2()
      import httplib2_test
      suite.addTests(httplib2_test.suite())
    except ImportError, e:
      raise e
  except Exception, e:
    logging.warning(e)
    logging.warning('memcache, datastore, and layered tests disabled.')
コード例 #2
0
ファイル: httplib2_test.py プロジェクト: jangxyz/ecogwiki
#!/usr/bin/python2.5

import test_utils
test_utils.init_appengine()
test_utils.init_httplib2()

import unittest
import datastore
import memory
import layered
from google.appengine.api import memcache
import httplib2

class HttpLib2Test(unittest.TestCase):

  def testHttpLib2(self):
    memory_cache = memory.Client()
    datastore_cache = datastore.Client()
    memcache_cache = memcache.Client()
    caches = [memory_cache, memcache_cache, datastore_cache]
    layered_cache = layered.Client(caches)
    layered_cache.flush_all()
    for cache in caches:
      self.assertEquals(0, cache.get_stats()['items'])
      self.assertEquals(0, cache.get_stats()['misses'])
      self.assertEquals(0, cache.get_stats()['hits'])
    http_client = httplib2.Http(layered_cache)
    url = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'
    # Fetch it once
    response, content = http_client.request(url)
    self.assertEquals(200, response.status)