Beispiel #1
0
def _test_store_fs_files(src_path):
    for store_fs in StoreFS.objects.all():
        fs_file = FSFile(store_fs)
        assert fs_file.fs == store_fs.fs
        assert fs_file.project == store_fs.project
        assert fs_file.store == store_fs.store
        assert fs_file.pootle_path == store_fs.pootle_path
        assert fs_file.path == store_fs.path

        # latest hash must be implemented by the plugin's file class
        with pytest.raises(NotImplementedError):
            fs_file.latest_hash

        if fs_file.exists:
            src_file_path = os.path.join(src_path, fs_file.path.strip("/"))
            with open(src_file_path, "r") as src_file:
                assert src_file.read() == fs_file.read()

        assert (
            str(fs_file)
            == ("<%s: %s::%s>"
                % (fs_file.__class__.__name__,
                   fs_file.pootle_path, fs_file.path)))
        directory = fs_file.directory
        if directory:
            if store_fs.store:
                assert directory == store_fs.store.parent
        else:
            assert not store_fs.store
        assert (
            fs_file.language
            == Language.objects.get(code=fs_file.pootle_path.split("/")[1]))
        assert (
            fs_file.translation_project
            == TranslationProject.objects.get(
                language=fs_file.language, project=fs_file.project))