Ejemplo n.º 1
0
def test_delete_mark_obsolete(project0_disk, store0):
    """Tests that the in-DB Store and Directory are marked as obsolete
    after the on-disk file ceased to exist.

    Refs. #269.
    """
    tp = TranslationProjectFactory(
        project=project0_disk, language=LanguageDBFactory()
    )
    store = StoreDBFactory(translation_project=tp, parent=tp.directory)

    store.update(store.deserialize(store0.serialize()))
    store.sync()
    pootle_path = store.pootle_path

    # Remove on-disk file
    os.remove(store.file.path)

    # Update stores by rescanning TP
    tp.scan_files()

    # Now files that ceased to exist should be marked as obsolete
    updated_store = Store.objects.get(pootle_path=pootle_path)
    assert updated_store.obsolete

    # The units they contained are obsolete too
    assert not updated_store.units.exists()
    assert updated_store.unit_set.filter(state=OBSOLETE).exists()
Ejemplo n.º 2
0
def ordered_po(test_fs, tp0):
    """Create a store with ordered units."""
    from tests.factories import StoreDBFactory

    store = StoreDBFactory(name="ordered.po",
                           translation_project=tp0,
                           parent=tp0.directory)
    with test_fs.open("data/po/ordered.po", "rb") as src:
        store.update(store.deserialize(src.read()))
    return store
Ejemplo n.º 3
0
def numbered_po(test_fs, project0_disk):
    """Create a store with numbered units."""
    from tests.factories import (
        LanguageDBFactory,
        StoreDBFactory,
        TranslationProjectFactory,
    )

    tp = TranslationProjectFactory(project=project0_disk,
                                   language=LanguageDBFactory())
    store = StoreDBFactory(name="numbered.po",
                           translation_project=tp,
                           parent=tp.directory)
    with test_fs.open("data/po/1234.po", "rb") as src:
        store.update(store.deserialize(src.read()))
    return store
Ejemplo n.º 4
0
def test_sync(project0_disk, store0):
    """Tests that the new on-disk file is created after sync for existing
    in-DB Store if the corresponding on-disk file ceased to exist.
    """
    tp = TranslationProjectFactory(project=project0_disk,
                                   language=LanguageDBFactory())
    store = StoreDBFactory(translation_project=tp, parent=tp.directory)

    store.update(store.deserialize(store0.serialize()))
    assert not store.file.exists()
    store.sync()
    assert store.file.exists()
    os.remove(store.file.path)
    assert not store.file.exists()
    store.sync()
    assert store.file.exists()