Commit 2b0acf33 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

Merge branch 'fix_no_has_config' into 'main'

Hashing option is now honored

Closes #1

See merge request thht/plus_sync!6
parents 39b1d0a6 594a2da7
Loading
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
import shutil
from functools import partial
from pathlib import Path

@@ -22,18 +23,18 @@ def configure_rclone(monkeypatch):


@pytest.fixture(scope='session')
def plus_sync():
def plus_sync_cmd():
    return partial(runner.invoke, ps_command.app)


@pytest.fixture(scope='function')
def initialized(plus_sync):
def initialized(plus_sync_cmd):
    # remove config file if it exists
    Path('plus_sync.toml').unlink(missing_ok=True)
    # remove data folder recursively if it exists
    if Path('data_synced').exists():
        Path('data_synced').rmdir()
    result = plus_sync(['init'], input='test\n')
        shutil.rmtree('data_synced')
    result = plus_sync_cmd(['init'], input='test\n')
    assert result.exit_code == 0
    assert 'Done' in result.stdout

+9 −1
Original line number Diff line number Diff line
@@ -4,12 +4,20 @@ import typer

from ...config import Config
from ..app import app
from ..helpers.typer import get_hashed_default


@app.command()
def list_subjects(
    remote_name: Annotated[str, typer.Argument(help='The name of the remote')],
    hash_subject_ids: Annotated[bool, typer.Option(help='Whether to hash the subject IDs.')] = True,
    hash_subject_ids: Annotated[
        bool,
        typer.Option(
            help='Whether to hash the subject IDs. Overrides the `has_subject_ids` setting.',
            default_factory=get_hashed_default,
            show_default=False,
        ),
    ],
):
    """
    List the subjects in a sync endpoint.
+9 −1
Original line number Diff line number Diff line
@@ -4,12 +4,20 @@ import typer

from ...config import Config
from ..app import app
from ..helpers.typer import get_hashed_default


@app.command(no_args_is_help=True)
def ls(
    remote_name: Annotated[str, typer.Argument(help='The name of the remote to use.')],
    hash_subject_ids: Annotated[bool, typer.Option(help='Whether to hash the subject IDs.')] = True,
    hash_subject_ids: Annotated[
        bool,
        typer.Option(
            help='Whether to hash the subject IDs. Overrides the `has_subject_ids` setting.',
            default_factory=get_hashed_default,
            show_default=False,
        ),
    ],
):
    """
    List the files that are available.
+9 −1
Original line number Diff line number Diff line
@@ -6,12 +6,20 @@ from tqdm import tqdm

from ...config import Config
from ..app import app
from ..helpers.typer import get_hashed_default


@app.command(no_args_is_help=True)
def sync(
    remote_name: Annotated[str, typer.Argument(help='The name of the remote to use.')],
    hash_subject_ids: Annotated[bool, typer.Option(help='Whether to hash the subject IDs.')] = True,
    hash_subject_ids: Annotated[
        bool,
        typer.Option(
            help='Whether to hash the subject IDs. Overrides the `has_subject_ids` setting.',
            default_factory=get_hashed_default,
            show_default=False,
        ),
    ],
    dry_run: Annotated[bool, typer.Option(help='Whether to do a dry run.')] = False,
    limit: Annotated[int, typer.Option(help='Limit the number of subjects to sync.')] = None,
):
+6 −0
Original line number Diff line number Diff line
from plus_sync.config import Config


def get_hashed_default() -> bool:
    config = Config.from_cmdargs()
    return config.hash_subject_ids
Loading