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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758#!/usr/bin/env python# -*- coding: utf-8 -*-
import pytest
from dolt_annex.file_keys import Sha256Efrom dolt_annex.gallery_dl_plugin import make_default_schemafrom dolt_annex.util.test_util import run
@pytest.mark.asyncioasync def test_import(temp_dir, setup): """ Test the basic functionality of the import subcommand. """
# A file path matching the pattern expected by dolt_annex.importers.gallerydl.GalleryDL file_path = temp_dir / "import_dir" / "posts" / "0" / "0" / "1_None.json" file_path.parent.mkdir(parents=True, exist_ok=True) with file_path.open('wb') as f: f.write(b"test image data")
expected_file_key = str(Sha256E.from_bytes(b"test image data", extension="json"))
make_default_schema("gallery-dl") await run( args=[ "dolt-annex", "script", "import", "--", "--importer", "gallerydl.GalleryDL test.com", "--move", "--dataset", "gallery-dl", "import_dir" ], )
# Verify that the file was imported into the dataset await run( args=[ "dolt-annex", "dataset", "read-table", "--dataset", "gallery-dl", "--table-name", "metadata", "--columns", "source", "--columns", "id", "--columns", "file_key" ], expected_output_equals=f'{{"source": "test.com/posts", "id": 1, "file_key": "{expected_file_key}"}}\n' ) await run( args=[ "dolt-annex", "filestore", "export-file", expected_file_key, ], expected_output_equals="test image data" )