Exemplo n.º 1
0
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(Path(tmppath), 'content')
    assert Path(p).exists()

    l._files.append(f)
    DBSession.add(l)
    DBSession.flush()
    DBSession.refresh(l)
    assert l.files
    assert l.audio
Exemplo n.º 2
0
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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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