Example #1
0
 def test_makeapp(self):
     from uliweb import manage
     
     manage.call('uliweb makeproject -y test')
     os.chdir('test')
     manage.call('uliweb makeapp Hello')
     os.chdir('..')
     assert os.path.exists('test/apps/Hello')
Example #2
0
 def test_makeapp(self):
     from uliweb import manage
     
     manage.call('uliweb makeproject -y test')
     os.chdir('test')
     manage.call('uliweb makeapp Hello')
     os.chdir('..')
     assert os.path.exists('test/apps/Hello')
    def setup(self):
        locate_dir = os.path.dirname(__file__)
        os.chdir(locate_dir)
        os.chdir('test_project')

        import shutil
        shutil.rmtree('database.db', ignore_errors=True)

        manage.call('uliweb syncdb')
        manage.call('uliweb syncspec')

        from uliweb.manage import make_simple_application
        app = make_simple_application(apps_dir='./apps')
Example #4
0
    def setup(self):

        locate_dir = os.path.dirname(__file__)
        os.chdir(locate_dir)
        os.chdir('test_project')
        self.reset_database()
        manage.call('uliweb syncspec')
        self.path = os.getcwd()

        from uliweb.manage import make_simple_application
        app = make_simple_application(apps_dir='./apps')

        print app
        from uliweb import settings
        print settings.SPECS
        from redbreast.core.spec import WFDatabaseStorage

        CoreWFManager.reset()
    def setup(self):
        
        locate_dir = os.path.dirname(__file__)
        os.chdir(locate_dir)
        os.chdir('test_project')
        self.reset_database()
        manage.call('uliweb syncspec')
        self.path = os.getcwd()

        from uliweb.manage import make_simple_application
        app = make_simple_application(apps_dir='./apps')
        
        print app
        from uliweb import settings
        print settings.SPECS
        from redbreast.core.spec import WFDatabaseStorage
        
        CoreWFManager.reset()
Example #6
0
def init():
    setup()
    manage.call('uliweb makeproject --yes TestProject')
    os.chdir('TestProject')
    path = os.getcwd()
    manage.call('uliweb makeapp Test')
    f = open('apps/Test/models.py', 'w')
    f.write('''
from uliweb.orm import *

class User(Model):
    username = Field(str)
    birth = Field(datetime.date)
    email =Field(str)
    
class Group(Model):
    name = Field(str)
    members = ManyToMany('user')
    manager = Reference('user')
    
class Blog(Model):
    sid = Field(str)
    subject = Field(str)
''')
    f.close()
    f = open('apps/settings.ini', 'w')
    f.write('''
[GLOBAL]
INSTALLED_APPS = [
'uliweb.contrib.redis_cli', 
'uliweb.contrib.orm', 
'uliweb.contrib.objcache', 
'Test'
]

[LOG]
level = 'info'

[LOG.Loggers]
uliweb.contrib.objcache = {'level':'info'}

[MODELS]
user = '******'
group = 'Test.models.Group'
blog = 'Test.models.Blog'

[OBJCACHE_TABLES]
user = '******', 'email'
group = 'name'
blog = {'key':'sid'}
''')
    f.close()
    manage.call('uliweb syncdb')
    app = manage.make_simple_application(project_dir=path)
Example #7
0
def init():
    setup()
    manage.call('uliweb makeproject --yes TestProject')
    os.chdir('TestProject')
    path = os.getcwd()
    manage.call('uliweb makeapp Test')
    f = open('apps/Test/models.py', 'w')
    f.write('''
from uliweb.orm import *

class User(Model):
    username = Field(str)
    birth = Field(datetime.date)
    email =Field(str)
    
class Group(Model):
    name = Field(str)
    members = ManyToMany('user')
    manager = Reference('user')
    
class Blog(Model):
    sid = Field(str)
    subject = Field(str)
''')
    f.close()
    f = open('apps/settings.ini', 'w')
    f.write('''
[GLOBAL]
INSTALLED_APPS = [
'uliweb.contrib.redis_cli', 
'uliweb.contrib.orm', 
'uliweb.contrib.objcache', 
'Test'
]

[LOG]
level = 'info'

[LOG.Loggers]
uliweb.contrib.objcache = {'level':'info'}

[MODELS]
user = '******'
group = 'Test.models.Group'
blog = 'Test.models.Blog'

[OBJCACHE_TABLES]
user = '******', 'email'
group = 'name'
blog = {'key':'sid'}
''')
    f.close()
    manage.call('uliweb syncdb')
    app = manage.make_simple_application(project_dir=path)
Example #8
0
    def test_makeproject(self):
        from uliweb import manage

        manage.call('uliweb makeproject -y test')
        assert os.path.exists('test')
Example #9
0
import os
from uliweb import manage
from uliweb.orm import *
import uliweb.orm as orm
from uliweb.manage import make_simple_application

os.chdir('test_orm_ext')
if os.path.exists('database.db'):
    os.remove('database.db')

manage.call('uliweb syncdb -v')

def test_extend_model():
    """
    >>> app = make_simple_application(project_dir='.', reuse=False)
    >>> U = get_model('user')
    >>> U.properties.keys()
    ['username', 'age', 'id']
    >>> U1 = get_model('user1')
    >>> U1.properties.keys()
    ['age', 'id']
    """

def test_dynamic_extend_model_1():
    """
    >>> app = make_simple_application(project_dir='.', reuse=False)
    >>> fields = [
    ...     {'name':'year', 'type':'int'}
    ... ]
    >>> U = create_model('user2', fields)
    >>> print U.properties.keys()
Example #10
0
import os
from uliweb import manage
from uliweb.orm import *
from uliweb.manage import make_simple_application

os.chdir('test_multidb')

manage.call('uliweb syncdb')
manage.call('uliweb syncdb --engine=b')


def test_is_in_web():
    """
    >>> app = make_simple_application(project_dir='.')
    >>> from uliweb import is_in_web
    >>> print is_in_web()
    False
    >>> from uliweb.utils.test import client
    >>> c = client('.')
    >>> r = c.get('/test_web')
    >>> print r.data
    True
    """
Example #11
0
import os
from uliweb import manage
from uliweb.orm import *
from uliweb.manage import make_simple_application

os.chdir("test_multidb")

manage.call("uliweb syncdb")
manage.call("uliweb syncdb --engine=b")


def test_is_in_web():
    """
    >>> app = make_simple_application(project_dir='.')
    >>> from uliweb import is_in_web
    >>> print is_in_web()
    False
    >>> from uliweb.utils.test import client
    >>> c = client('.')
    >>> r = c.get('/test_web')
    >>> print r.data
    True
    """
Example #12
0
import os
from uliweb import manage
from uliweb.orm import *
from uliweb.manage import make_simple_application

os.chdir('test_multidb')

manage.call('uliweb syncdb -v')
manage.call('uliweb syncdb -v --engine=b')
manage.call('uliweb syncdb -v --engine=c')


def test_1():
    """
    >>> app = make_simple_application(project_dir='.')
    >>> import uliweb.orm as orm
    >>> print '__models__', orm.__models__
    __models__ {'blog': {'config': {}, 'model_path': 'blog.models.Blog', 'engines': ['default', 'b'], 'appname': 'blog'}, 'category': {'config': {}, 'model_path': 'blog.models.Category', 'engines': ['b'], 'appname': 'blog'}}
    >>> print engine_manager['default'].models
    {'blog': {'model': <class 'blog.models.Blog'>, 'created': None, 'model_path': 'blog.models.Blog', 'appname': 'blog'}}
    >>> print engine_manager['b'].models
    {'blog': {'model': <class 'uliweb.orm.Blog'>, 'created': None, 'model_path': 'blog.models.Blog', 'appname': 'blog'}, 'category': {'model': <class 'blog.models.Category'>, 'created': None, 'model_path': 'blog.models.Category', 'appname': 'blog'}}
    >>> Blog1 = get_model('blog')
    >>> Blog2 = get_model('blog', 'b')
    >>> print 'blog2', Blog2, Blog2.table, Blog2.tablename, Blog2.get_engine_name(), Blog2.get_connection()
    blog2 <class 'uliweb.orm.Blog'> blog blog b b
    >>> print 'blog1', Blog1, Blog1.table, Blog1.tablename, Blog1.get_engine_name(), Blog1.get_connection()
    blog1 <class 'blog.models.Blog'> blog blog default default
    >>> r = Blog2.all().remove()
    >>> r = Blog1.all().remove()
    >>> b2 = Blog2(title='1', content='1')
 def create_database(self):
     self.remove_database()
     manage.call('uliweb syncdb')
     manage.call('uliweb syncspec')
Example #14
0
    def test_makeproject(self):
        from uliweb import manage

        manage.call('uliweb makeproject -y test')
        assert os.path.exists('test')
Example #15
0
 def reset_database(self):
     import shutil
     shutil.rmtree('database.db', ignore_errors=True)
     manage.call('uliweb syncdb')
 def reset_database(self):
     import shutil
     shutil.rmtree('database.db', ignore_errors=True)
     manage.call('uliweb syncdb')
Example #17
0
import os
from uliweb import manage
from uliweb.orm import *
from uliweb.manage import make_simple_application

os.chdir('test_multidb')

manage.call('uliweb syncdb -v')
manage.call('uliweb syncdb -v --engine=b')
manage.call('uliweb syncdb -v --engine=c')

def test_1():
    """
    >>> app = make_simple_application(project_dir='.')
    >>> import uliweb.orm as orm
    >>> print '__models__', orm.__models__
    __models__ {'blog': {'config': {}, 'model_path': 'blog.models.Blog', 'engines': ['default', 'b'], 'appname': 'blog'}, 'category': {'config': {}, 'model_path': 'blog.models.Category', 'engines': ['b'], 'appname': 'blog'}}
    >>> print engine_manager['default'].models
    {'blog': {'model': <class 'blog.models.Blog'>, 'created': None, 'model_path': 'blog.models.Blog', 'appname': 'blog'}}
    >>> print engine_manager['b'].models
    {'blog': {'model': <class 'uliweb.orm.Blog'>, 'created': None, 'model_path': 'blog.models.Blog', 'appname': 'blog'}, 'category': {'model': <class 'blog.models.Category'>, 'created': None, 'model_path': 'blog.models.Category', 'appname': 'blog'}}
    >>> Blog1 = get_model('blog')
    >>> Blog2 = get_model('blog', 'b')
    >>> print 'blog2', Blog2, Blog2.table, Blog2.tablename, Blog2.get_engine_name(), Blog2.get_session()
    blog2 <class 'uliweb.orm.Blog'> blog blog b <Session engine_name:b, auto_transaction=None, auto_close=True>
    >>> print 'blog1', Blog1, Blog1.table, Blog1.tablename, Blog1.get_engine_name(), Blog1.get_session()
    blog1 <class 'blog.models.Blog'> blog blog default <Session engine_name:default, auto_transaction=None, auto_close=True>
    >>> r = Blog2.all().remove()
    >>> r = Blog1.all().remove()
    >>> b2 = Blog2(title='1', content='1')
    >>> b2.save()
 def create_database(self):
     self.remove_database()
     manage.call('uliweb syncdb')
     manage.call('uliweb syncspec')