Beispiel #1
0
 def test_invoke(self):
     """method invoking using inspector"""
     inspector = ModuleInspector(sys.modules[__name__])
     inspector.invoke()
     inspector.invoke("greetings")
     inspector.invoke("greetings", "aaa")
     inspector.invoke("greetings", "aaa", "bbb")
     inspector.invoke(None, "aaa")
     inspector.invoke(None, "aaa", "bbb")
     inspector.invoke(None, "aaa", "bbb", "ccc")
Beispiel #2
0
    create_tables()


def load_data():
    """Load data into database from fixtures.py"""
    from everblog import fixtures
    db.load_data(fixtures)
    print 'Data loaded'


def recreate_tables_then_load_data():
    """Recreate all tables and load the fixtures data"""
    drop_tables()
    create_tables()
    load_data()


def run_app():
    """Run the web application"""
    from everblog import app
    if len(sys.argv) < 2:
        subprocess.call([sys.executable, 'manage.py', 'run_app'])
    else:
        app.run(host = '0.0.0.0')


if __name__ == '__main__':
    from toolkit_library.inspector import ModuleInspector
    inspector = ModuleInspector(sys.modules[__name__])
    inspector.invoke(*sys.argv[1:])
Beispiel #3
0
from toolkit_library.inspector import ModuleInspector, PackageInspector
from toolkit_library.input_util import InputUtil
from quick_orm import examples


def run_examples():
    """Run all of the examples"""
    # automatically install the newest code before testing
    subprocess.call([sys.executable, 'setup.py', 'install'])

    # call each example file and print the result
    for module in PackageInspector(examples).get_all_modules():
        print '****** {0} ******'.format(module)
        subprocess.call(
            [sys.executable, 'quick_orm/examples/{0}.py'.format(module)])
        print


def run_tests():
    """Run unit tests"""
    from quick_orm.testsuite import run_testsuite
    db_name = InputUtil.get_input('database',
                                  default='sqlite',
                                  pattern='(?:mysql|sqlite|postgresql)')
    run_testsuite(db_name)


if __name__ == '__main__':
    inspector = ModuleInspector(sys.modules[__name__])
    inspector.invoke(*sys.argv[1:])
Beispiel #4
0
# coding=utf-8
"""
    everblog.fixtures
    ~~~~~~~~~~~~~~~~~
    Contains fixtures data to be inserted into database
"""
import everblog.models
from toolkit_library.inspector import ModuleInspector

moduleInspector = ModuleInspector(everblog.models)
exec(moduleInspector.import_all_classes_statement())

blog_entries = [
    BlogEntry(
        evernote_url=
        'http://www.evernote.com/shard/s68/sh/f69937b9-7cb1-414d-91ef-baca869dc263/f08695a8be5d370a4aba8ed8e141eb1e'
    ),
    BlogEntry(
        evernote_url=
        'http://www.evernote.com/shard/s68/sh/4d56d15c-250e-448e-8754-d7e17df66afe/72b4b597391d43cdf88948c3ad3c6446'
    ),
]
for blog_entry in blog_entries:
    blog_entry.synchronize()

pages = [
    Page(
        order=1,
        evernote_url=
        'http://www.evernote.com/shard/s68/sh/f0df80b6-70c2-4858-b916-6e09b20a080d/b443c66aea7c40fe6ab68480f16094f8'
    ),
Beispiel #5
0
# coding=utf-8
"""
    quick_orm.testsuite.core
    ~~~~~~~~~~~~~~~~~~~~~~~~
    test the core of quick_orm
"""
import unittest
from toolkit_library.inspector import ModuleInspector
import quick_orm.testsuite.models as models
from quick_orm.testsuite import db

exec(ModuleInspector(models).import_all_classes_statement())


class CoreTestCase(unittest.TestCase):
    """The default test case"""
    def tearDown(self):
        db.session.remove()

    def test_many_to_one(self):
        """Test many_to_one relationship"""
        user = db.session.query(User).filter_by(name='simon').first()
        assert user
        assert user.blog_entries.count() > 0
        assert user.blog_entries.first().user.name == 'simon'

    def test_many_to_many(self):
        """Test many_to_many relationship"""
        user = db.session.query(User).filter_by(name='simon').first()
        assert user
        assert user.groups.count() > 0
Beispiel #6
0
# coding=utf-8
"""
    quick_orm.testsuite.fixtures
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sample data for testing purpose
"""
from toolkit_library.inspector import ModuleInspector 
import quick_orm.testsuite.models

exec(ModuleInspector(quick_orm.testsuite.models).import_all_classes_statement())

users = []
users.append(User(name = 'peter'))
users.append(User(name = 'tyler'))
users.append(User(name = 'simon'))
users.append(User(name = 'jason'))
users.append(User(name = 'justin'))

groups = []
groups.append(Group(name = 'admin', users = [users[0],]))
groups.append(Group(name = 'editor', users = [users[1], users[3], users[4], ]))
groups.append(Group(name = 'user', users = [users[2],]))

blog_entries = []
blog_entries.append(BlogEntry(title = 'blog_entry_title_1',  content = 'blog_entry_content_1',  user = users[0]))
blog_entries.append(BlogEntry(title = 'blog_entry_title_2',  content = 'blog_entry_content_2',  user = users[1]))
blog_entries.append(BlogEntry(title = 'blog_entry_title_3',  content = 'blog_entry_content_3',  user = users[2]))
blog_entries.append(BlogEntry(title = 'blog_entry_title_4',  content = 'blog_entry_content_4',  user = users[2]))
blog_entries.append(BlogEntry(title = 'blog_entry_title_5',  content = 'blog_entry_content_5',  user = users[3]))
blog_entries.append(BlogEntry(title = 'blog_entry_title_6',  content = 'blog_entry_content_6',  user = users[3]))
blog_entries.append(BlogEntry(title = 'blog_entry_title_7',  content = 'blog_entry_content_7',  user = users[4]))
Beispiel #7
0
# coding=utf-8
"""
    everblog.fixtures
    ~~~~~~~~~~~~~~~~~
    Contains fixtures data to be inserted into database
"""
import everblog.models
from toolkit_library.inspector import ModuleInspector

moduleInspector = ModuleInspector(everblog.models)
exec(moduleInspector.import_all_classes_statement())


blog_entries = [
    BlogEntry(
        evernote_url="http://www.evernote.com/shard/s68/sh/f69937b9-7cb1-414d-91ef-baca869dc263/f08695a8be5d370a4aba8ed8e141eb1e"
    ),
    BlogEntry(
        evernote_url="http://www.evernote.com/shard/s68/sh/4d56d15c-250e-448e-8754-d7e17df66afe/72b4b597391d43cdf88948c3ad3c6446"
    ),
]
for blog_entry in blog_entries:
    blog_entry.synchronize()


pages = [
    Page(
        order=1,
        evernote_url="http://www.evernote.com/shard/s68/sh/f0df80b6-70c2-4858-b916-6e09b20a080d/b443c66aea7c40fe6ab68480f16094f8",
    ),
    Page(