Something went wrong. Try again.
Manage a distributed indexed dataset of files and metadata, using a Dolt database to track who has copies of what.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596# Validate that example configuration files are correct by# - loading them and seeing that they validate and match# - regenerating them produces the same output as the original file
import contextlibimport osimport pathlibimport uuid
from dolt_annex.filestore.annexfs import AnnexFSModelfrom dolt_annex.filestore.base import FileStoreModelfrom dolt_annex.filestore.sftp import SftpFileStoreModelimport pyjson5
from dolt_annex.config.base import Config, UserConfig, DoltConfig, SshSettingsfrom dolt_annex.config.connection import MySQLConnection, SSHConnectionfrom dolt_annex.datatypes.table import DatasetSchema, FileTableSchemafrom dolt_annex.file_keys import Sha256E
def test_example_config(): example_config = Config( user = UserConfig( name="A U Thor", email="author@example.com", ), dolt = DoltConfig( default_remote="origin", default_commit_message="update", connection=MySQLConnection( user="root", hostname="localhost", port=3306, server_socket=pathlib.Path("/tmp/dolt.sock"), database="dolt", ), spawn_dolt_server=True, ), ssh = SshSettings( ssh_config=pathlib.Path("~/.ssh/config"), known_hosts=pathlib.Path("~/.ssh/known_hosts"), ), local_repo="__local__", default_annex_remote="origin", default_file_key_type=Sha256E, )
example_local_repo = AnnexFSModel( name = "__local__", uuid = uuid.UUID("fedcba98-7654-3210-ca11-8675309abcde"),
root=pathlib.Path("./annex"), )
example_remote_repo = SftpFileStoreModel( name = "sftp", uuid = uuid.UUID("12345678-9abc-def0-cafe-cba987654321"),
connection=SSHConnection( user="your_username", hostname="sftp.example.com", port=22, client_key=pathlib.Path("~/.ssh/id_rsa"), path=pathlib.Path("."), ) )
example_dataset_schema = DatasetSchema( name="file_archive", tables = [ FileTableSchema( name="files", file_column="file_key", key_columns=["path"], ), ], empty_table_ref = "file_archive" )
with contextlib.chdir(os.path.dirname(__file__)): with open("example_config.json5", encoding="utf-8") as f: loaded_config = Config.model_validate(pyjson5.decode(f.read())) assert loaded_config == example_config with open("filestores/__local__.filestore", encoding="utf-8") as f: loaded_local_repo = FileStoreModel.model_validate(pyjson5.decode(f.read())) assert loaded_local_repo == example_local_repo
with open("filestores/sftp.filestore", encoding="utf-8") as f: loaded_remote_repo = FileStoreModel.model_validate(pyjson5.decode(f.read())) assert loaded_remote_repo == example_remote_repo
with open("file_archive.dataset", encoding="utf-8") as f: loaded_file_archive = DatasetSchema.model_validate(pyjson5.decode(f.read())) assert loaded_file_archive == example_dataset_schema