示例#1
0
 def setUp(self):
     """Create a new database."""
     self.ctx = Context(cfg)
     self.ctx.create_all()
     self.session = self.ctx.session
     setup.add_enums(self.ctx)
     self.enum = setup.ENUM
示例#2
0
 def setUp(self):
     """Create a new database."""
     self.ctx = Context(cfg)
     self.ctx.create_all()
     self.session = self.ctx.session
     setup.add_enums(self.ctx)
     self.enum = setup.ENUM
示例#3
0
class SchemaTestCase(TestCase):
    """Creates a new database before every test. This also provides some
    helper code.
    """
    def setUp(self):
        """Create a new database."""
        self.ctx = Context(cfg)
        self.ctx.create_all()
        self.session = self.ctx.session
        setup.add_enums(self.ctx)
        self.enum = setup.ENUM

    def add_root(self, name):
        """Add a root with the given name.

        :param name: the name of the root.
        """
        root = Root(name=name)
        self.session.add(root)
        self.session.commit()
        return root
示例#4
0
class SchemaTestCase(TestCase):

    """Creates a new database before every test. This also provides some
    helper code.
    """

    def setUp(self):
        """Create a new database."""
        self.ctx = Context(cfg)
        self.ctx.create_all()
        self.session = self.ctx.session
        setup.add_enums(self.ctx)
        self.enum = setup.ENUM

    def add_root(self, name):
        """Add a root with the given name.

        :param name: the name of the root.
        """
        root = Root(name=name)
        self.session.add(root)
        self.session.commit()
        return root
示例#5
0
    def setUp(self):
        """Load all sandhi rules into the database."""
        s = str.split
        self.two_split = [
            (s('kim akurvata'), 'kim akurvata'),
            (s('tat hita'), 'tad Dita'),
            (s('kanyA fcCati'), 'kanyarcCati'),
            (s('PalAni alaBat'), 'PalAny alaBat'),
            (s('yogin arjuna'), 'yoginn arjuna'),
            (s('narEs agacCat'), 'narEr agacCat'),
            ]
        self.three_split = [
            (s('pARqavAS ca eva'), 'pARqavAS cEva'),
            (['tasmin', 'Pale', 'iti'], 'tasmin Pala iti'),
            (['te', sandhi.Exempt('Pale'), 'iti'], 'te Pale iti'),
            ]

        ctx = Context(cfg)
        ctx.create_all()
        S.add_enums(ctx)
        S.add_sandhi(ctx)

        self.sandhi = sandhi.Sandhi()
        self.sandhi.load(ctx)
示例#6
0
def sa_drop_all():
    """Drops tables for `sanskrit`."""
    if prompt_bool('This will drop all linguistic data. Proceed?'):
        ctx = Context(app.config)
        ctx.drop_all()
示例#7
0
def sa_seed_all(*blueprints):
    """Seeds tables for `sanskrit`."""
    # TODO: fix this
    if prompt_bool('This will drop then recreate all linguistic data. Proceed?'):
        ctx = Context(app.config)
        ctx.build()
示例#8
0
test.query
~~~~~~~~~~

Tests something.

:license: MIT and BSD
"""

from sanskrit import Context
from sanskrit import setup as S  # ``as S`` avoids problems with nose
from sanskrit.query import SimpleQuery
from sanskrit.schema import *

from . import TestCase, config as cfg

ctx = Context(cfg)
db_built = False


class QueryTestCase(TestCase):

    def setUp(self):
        """Initialize the database if it doesn't exist."""
        global db_built

        if not db_built:
            ctx.drop_all()
            ctx.create_all()
            S.run(ctx)
            db_built = True
示例#9
0
 def testOverride(self):
     """Test overriding a default option"""
     config = dict(DATABASE_URI=cfg.DATABASE_URI, DATA_PATH=cfg.DATA_PATH,
                   MONIER_XML_PATH='foo')
     ctx = Context(config)
     self.assertEqual(ctx.config['MONIER_XML_PATH'], 'foo')
示例#10
0
 def testDict(self):
     """Test creating from a :class:`dict`."""
     config = dict(DATABASE_URI=cfg.DATABASE_URI, DATA_PATH=cfg.DATA_PATH)
     ctx = Context(config)
     self.compare_all(ctx)
示例#11
0
 def testModule(self):
     """Test creating from a module."""
     ctx = Context(cfg)
     self.compare_all(ctx)
示例#12
0
 def testFile(self):
     """Test creating from a filename."""
     path = os.path.join(os.path.dirname(__file__), 'config.py')
     ctx = Context(path)
     self.compare_all(ctx)