Exemple #1
0
def setup():
    donri = Root(id="donri", affixes=["dor", "do'i"])
    donri.history("en").revise(object=Definition(definition="x1 is the daytime...", notes="See also {nicte}..."))

    with db() as root:
        root["entries"]["donri"] = donri

    yield
Exemple #2
0
def write(client):
    """Views can write to the database"""

    @current_app.route('/_test/<value>')
    def write_value(value):
        db['_test'] = value

    client.get('/_test/Written!')

    with db() as root:
        assert var(root['_test']) == 'Written!'
Exemple #3
0
def read(client):
    """Views can read from the database"""

    with db() as root:
        root['_test'] = 'Victory!'

    @current_app.route('/_test/')
    def read_value():
        return db['_test']

    response = client.get('/_test/')
    assert response.data == 'Victory!'
Exemple #4
0
def xml(client):
    """XML export contains the right elements and attributes"""

    cipra = Root(id='cipra', affixes=['cip'])
    cipra.history('en').revise(object=Definition(
        definition='x1 is a test...',
        notes='Also examination, proxy measure, validation...'
    ))

    with db() as root:
        root['entries']['cipra'] = cipra

    response = client.get('/dict/+export/en/')

    xpaths = (
        '/dictionary/direction[@from="Lojban"][@to="English"]',
        '//valsi[@word="cipra"][@type="gismu"]/rafsi = "cip"',
        '//definition = "x1 is a test..."',
        '//notes = "Also examination, proxy measure, validation..."'
    )

    for path in xpaths:
        assert_xml(response, path)
Exemple #5
0
def entry():
    with db() as root:
        root['entries']['donri'] = None
    assert var(schemata.Entry('donri').validate()).is_(True)
    assert var(schemata.Entry('claxu').validate()).is_(False)
Exemple #6
0
 def validate(self, element, state):
     with db() as root:
         if element.value not in root['entries']:
             return self.note_error(element, state, 'undefined_entry')
     return True