def test_compute_language_sources(self): from clld.db.models.common import Source, Sentence, Language, SentenceReference from clld.db.meta import DBSession from clld.db.util import compute_language_sources s = Sentence(id='sentenced', language=Language(id='newlang')) sr = SentenceReference(sentence=s, source=Source.first()) DBSession.add(sr) DBSession.flush() compute_language_sources()
def test_Files(db, tmppath): from clld.db.models.common import Sentence, Sentence_files l = Sentence(id='abc', name='Name') f = Sentence_files(object=l, id='abstract', mime_type='audio/mpeg') p = f.create(tmppath, 'content') assert Path(p).exists() l._files.append(f) DBSession.add(l) DBSession.flush() DBSession.refresh(l) assert l.files assert l.audio
def test_Files(self): from clld.db.models.common import Sentence, Sentence_files if PY3: return # pragma: no cover l = Sentence(id='abc', name='Name') f = Sentence_files(object=l, id='abstract', mime_type='audio/mpeg') p = f.create( Path(mkdtemp()).joinpath('clldtest').as_posix(), 'content') assert os.path.exists(p) rmtree(Path(p).parent.parent) l._files.append(f) DBSession.add(l) DBSession.flush() DBSession.refresh(l) assert l.files assert l.audio
def test_Files(self): from clld.db.models.common import Sentence, Sentence_files from path import path if PY3: return # pragma: no cover l = Sentence(id='abc', name='Name') f = Sentence_files(object=l, id='abstract', mime_type='audio/mpeg') p = f.create(path(gettempdir()), 'content') assert os.path.exists(p) os.remove(p) l._files.append(f) DBSession.add(l) DBSession.flush() DBSession.refresh(l) assert l.files assert l.audio