Пример #1
0
 def test_add_pool(self):
     servers = ['localhost:1234', 'localhost:5678']
     conn.add_pool(__name__, servers)
     self.assert_(conn._SERVERS[__name__] == servers)
Пример #2
0
 def test_add_pool(self):
     servers = ["localhost:1234", "localhost:5678"]
     conn.add_pool(__name__, servers)
     self.assert_(conn._SERVERS[__name__]["servers"] == servers)
Пример #3
0
 def test_add_pool(self):
     servers = ['localhost:1234', 'localhost:5678']
     conn.add_pool(__name__, servers)
     self.assert_(conn._SERVERS[__name__]["servers"] == servers)
Пример #4
0
# Python imports
import unittest
import time
import logging
from lazyboy import models
from lazyboy import connection

NOW = int(time.time())

connection.add_pool('Tests', ['127.0.0.1:9162'])

class ModelTestCase(unittest.TestCase):
    pass


class TestModelInheritance(ModelTestCase):
    def test_inheritance(self):
        class ParentModel(models.Model):
            class Meta:
                keyspace = "ParentModels"
                column_family = "ParentModel"

            id = models.KeyField()
            name = models.CharField()

        class ChildModel(ParentModel):
            pass


class TestField(ModelTestCase):
    class MyModel(models.Model):
Пример #5
0
  def __iter__(self):
    if hasattr(self.response, "__len__"):
      self.headers['Content-length'] = str(len(self.response))
    headers = [(header, value) for header, value in self.headers.items()]
    self.start_response(self.status, headers)
    yield self.response

class Template:
  """A simple wrapper to string.Template class.
  """

  @staticmethod
  def render(template_str=None, filename=None, **kwargs):
    if filename:
      filename = path.join("./templates", filename)
      template_str = open(filename).read()

    template =  string.Template(template_str).safe_substitute(kwargs)
    return template

if __name__ == "__main__":
  from wsgiref.simple_server import make_server
  server = make_server("", 8000, Cacilda)
  print("Listening to port 8000…")
  try:
    connection.add_pool("Cacilda", ["localhost:9160"])
    server.serve_forever()
  except KeyboardInterrupt as stopped_by_user_error:
    print("Shutting server down.")
Пример #6
0
 def test_add_pool(self):
     servers = ['localhost:1234', 'localhost:5678']
     conn.add_pool(__name__, servers)
     self.failUnless(conn.get_pool(__name__))