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
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!'
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!'
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)
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)
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