X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/e080215f07b8153ef01d6c840a4ba3a4bfc2d770..dc9ecbad36153af00773b4951120b4697b33193e:/floof/tests/__init__.py?ds=sidebyside diff --git a/floof/tests/__init__.py b/floof/tests/__init__.py index d51f6f2..fc14a48 100644 --- a/floof/tests/__init__.py +++ b/floof/tests/__init__.py @@ -16,14 +16,68 @@ from routes.util import URLGenerator from webtest import TestApp import pylons.test +from elixir import * +from floof.model import * +from floof.model import meta +from floof import model as model +from sqlalchemy import engine_from_config + +__all__ = ['environ', 'url', 'TestController', 'TestModel'] -__all__ = ['environ', 'url', 'TestController'] # Invoke websetup with the current config file -SetupCommand('setup-app').run([config['__file__']]) +# SetupCommand('setup-app').run([config['__file__']]) + +# additional imports ... +import os +from paste.deploy import appconfig +from floof.config.environment import load_environment +here_dir = os.path.dirname(__file__) +conf_dir = os.path.dirname(os.path.dirname(here_dir)) + +test_file = os.path.join(conf_dir, 'test.ini') +conf = appconfig('config:' + test_file) +load_environment(conf.global_conf, conf.local_conf) environ = {} +engine = engine_from_config(config, 'sqlalchemy.') +model.init_model(engine) +metadata = elixir.metadata +Session = elixir.session = meta.Session + +class Individual(Entity): + """Table 'Individual'. + + >>> me = Individual('Groucho') + + # 'name' field is converted to lowercase + >>> me.name + 'groucho' + """ + name = Field(String(20), unique=True) + favorite_color = Field(String(20)) + + def __init__(self, name, favorite_color=None): + self.name = str(name).lower() + self.favorite_color = favorite_color + +setup_all() + +def setup(): + pass + +def teardown(): + pass + +class TestModel(TestCase): + def setUp(self): + setup_all(True) + + def tearDown(self): + drop_all(engine) + + class TestController(TestCase): def __init__(self, *args, **kwargs):