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

Merge branch 'add_tests' into 'main'

Add tests and coverage

See merge request thht/plus_sync!5
parents e6cf4ce8 a448ba48
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -78,3 +78,6 @@ sync.toml
data_synced
plus_sync.toml
.pypirc
.pytest_cache
.ruff_cache
coverage.lcov

.gitlab-ci.yml

0 → 100644
+17 −0
Original line number Diff line number Diff line
default:
  image: debian:latest
  before_script: |
    apt-get update
    apt-get install -y curl git build-essential rclone
    curl -fsSL https://pixi.sh/install.sh | bash
    export PATH=$PATH:/root/.pixi/bin
    curl -L https://coveralls.io/coveralls-linux.tar.gz | tar -xz -C /usr/local/bin

test:
  script: |
    pixi run ruff_ci
    pixi run test
    coveralls report
  rules:
  - if: $CI_MERGE_REQUEST_ID
  - if: $CI_COMMIT_BRANCH == 'main'
 No newline at end of file

.vscode/settings.json

0 → 100644
+7 −0
Original line number Diff line number Diff line
{
    "python.testing.pytestArgs": [
        "tests"
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.pytestEnabled": true
}
 No newline at end of file

conftest.py

0 → 100644
+47 −0
Original line number Diff line number Diff line
from functools import partial
from pathlib import Path

import pytest
from typer.testing import CliRunner

import plus_sync.cmd as ps_command

runner = CliRunner()


@pytest.fixture(autouse=True)
def to_temp_folder(monkeypatch, tmp_path):
    monkeypatch.chdir(tmp_path)
    yield tmp_path


@pytest.fixture(autouse=True)
def configure_rclone(monkeypatch):
    monkeypatch.setenv('RCLONE_CONFIG', 'rclone.conf')
    yield


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


@pytest.fixture(scope='function')
def initialized(plus_sync):
    # 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')
    assert result.exit_code == 0
    assert 'Done' in result.stdout


@pytest.fixture
def sftp_fixture(sftpserver):
    # https://github.com/ulope/pytest-sftpserver/issues/30
    # Tests hanging forever
    sftpserver.daemon_threads = True
    sftpserver.block_on_close = False
    yield sftpserver
+170 −2
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/linux-64/cffi-1.16.0-py312hf06ca03_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/cfgv-3.3.1-pyhd8ed1ab_0.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/click-8.1.7-unix_pyh707e725_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/colorama-0.4.6-pyhd8ed1ab_0.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/comm-0.2.2-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/coverage-7.5.4-py312h9a8786e_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/cryptography-42.0.8-py312hbcc2302_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/dbus-1.13.6-h5008d03_3.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/linux-64/debugpy-1.8.1-py312h30efb56_0.conda
@@ -29,6 +31,8 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/noarch/exceptiongroup-1.2.0-pyhd8ed1ab_2.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/executing-2.0.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/expat-2.6.2-h59595ed_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/factory_boy-3.3.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/faker-25.9.2-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/filelock-3.14.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/h11-0.14.0-pyhd8ed1ab_0.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/h2-4.1.0-pyhd8ed1ab_0.tar.bz2
@@ -45,6 +49,7 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/noarch/importlib-metadata-7.1.0-pyha770c72_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/importlib_metadata-7.1.0-hd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/importlib_resources-6.4.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/iniconfig-2.0.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/ipykernel-6.29.4-pyh3099207_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/ipython-8.25.0-pyh707e725_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.classes-3.4.0-pyhd8ed1ab_1.conda
@@ -95,6 +100,8 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/noarch/pure_eval-0.2.2-pyhd8ed1ab_0.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/pycparser-2.22-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.18.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-8.2.2-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-5.0.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.12.3-hab00c5b_0_cpython.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/python_abi-3.12-4_cp312.conda
@@ -111,6 +118,7 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/noarch/sniffio-1.3.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/stack_data-0.6.2-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/tk-8.6.13-noxft_h4845f30_101.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/toml-0.10.2-pyhd8ed1ab_0.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.0.1-pyhd8ed1ab_0.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-w-1.0.0-pyhd8ed1ab_0.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/tomlkit-0.12.5-pyha770c72_0.conda
@@ -139,6 +147,7 @@ environments:
      - pypi: https://files.pythonhosted.org/packages/91/29/df4b9b42f2be0b623cbd5e2140cafcaa2bef0759a00b7b70104dcfe2fb51/joblib-1.4.2-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/ad/50/8792484502c8141c20c996b802fefa8435a9c018a2bb440a06b172782118/paramiko-3.4.0-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/ee/87/f1bb6a595f14a327e8285b9eb54d41fef76c585a0edef0a45f6fc95de125/PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
      - pypi: https://files.pythonhosted.org/packages/5c/07/a66ce67849514133361887636e0ca187e894bca241686adedd414a06cb50/pytest_sftpserver-1.3.0-py2.py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/75/e8/6367f58f9bf0c35faf4e1bf2fd90a3296f37263971cbbef3e056e2e70f79/python_gitlab-4.6.0-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/8d/85/699be9823e7c0a617efdf576d5bd38d85e7dccaed7d8caad4f854be53f44/quickxorhash-1.0.5.tar.gz
      - pypi: https://files.pythonhosted.org/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl
@@ -430,6 +439,23 @@ packages:
  - pkg:pypi/click?source=conda-forge-mapping
  size: 84437
  timestamp: 1692311973840
- kind: conda
  name: colorama
  version: 0.4.6
  build: pyhd8ed1ab_0
  subdir: noarch
  noarch: python
  url: https://conda.anaconda.org/conda-forge/noarch/colorama-0.4.6-pyhd8ed1ab_0.tar.bz2
  sha256: 2c1b2e9755ce3102bca8d69e8f26e4f087ece73f50418186aee7c74bef8e1698
  md5: 3faab06a954c2a04039983f2c4a50d99
  depends:
  - python >=3.7
  license: BSD-3-Clause
  license_family: BSD
  purls:
  - pkg:pypi/colorama?source=conda-forge-mapping
  size: 25170
  timestamp: 1666700778190
- kind: conda
  name: comm
  version: 0.2.2
@@ -448,6 +474,25 @@ packages:
  - pkg:pypi/comm?source=conda-forge-mapping
  size: 12134
  timestamp: 1710320435158
- kind: conda
  name: coverage
  version: 7.5.4
  build: py312h9a8786e_0
  subdir: linux-64
  url: https://conda.anaconda.org/conda-forge/linux-64/coverage-7.5.4-py312h9a8786e_0.conda
  sha256: 2902fb27f4a6b16512264973b13fea7ddb81811ba8599906a737d3cc1ee24db0
  md5: b40224324679d1966a9fafbd602b28f3
  depends:
  - libgcc-ng >=12
  - python >=3.12,<3.13.0a0
  - python_abi 3.12.* *_cp312
  - tomli
  license: Apache-2.0
  license_family: APACHE
  purls:
  - pkg:pypi/coverage?source=conda-forge-mapping
  size: 361123
  timestamp: 1719113789335
- kind: conda
  name: cryptography
  version: 42.0.8
@@ -606,6 +651,42 @@ packages:
  purls: []
  size: 137627
  timestamp: 1710362144873
- kind: conda
  name: factory_boy
  version: 3.3.0
  build: pyhd8ed1ab_0
  subdir: noarch
  noarch: python
  url: https://conda.anaconda.org/conda-forge/noarch/factory_boy-3.3.0-pyhd8ed1ab_0.conda
  sha256: 78cbfc6781540e65138e1b09806a6e49c899d434c013b030beb51d7340300bb8
  md5: dbcc5a2249cd7f87db66b8a103920609
  depends:
  - faker >=0.7.0
  - python >=3.8
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/factory-boy?source=conda-forge-mapping
  size: 35834
  timestamp: 1689773927608
- kind: conda
  name: faker
  version: 25.9.2
  build: pyhd8ed1ab_0
  subdir: noarch
  noarch: python
  url: https://conda.anaconda.org/conda-forge/noarch/faker-25.9.2-pyhd8ed1ab_0.conda
  sha256: 087c8fb650f639f35904249f8d4bac6c5c06fd77648439f27945bd08fa9e8e57
  md5: cda7063caadf47a2ac1633bc80a89f7e
  depends:
  - python >=3.8
  - python-dateutil >=2.4
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/faker?source=conda-forge-mapping
  size: 1391435
  timestamp: 1719386114688
- kind: conda
  name: filelock
  version: 3.14.0
@@ -921,6 +1002,23 @@ packages:
  - pkg:pypi/importlib-resources?source=conda-forge-mapping
  size: 33056
  timestamp: 1711041009039
- kind: conda
  name: iniconfig
  version: 2.0.0
  build: pyhd8ed1ab_0
  subdir: noarch
  noarch: python
  url: https://conda.anaconda.org/conda-forge/noarch/iniconfig-2.0.0-pyhd8ed1ab_0.conda
  sha256: 38740c939b668b36a50ef455b077e8015b8c9cf89860d421b3fff86048f49666
  md5: f800d2da156d08e289b14e87e43c1ae5
  depends:
  - python >=3.7
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/iniconfig?source=conda-forge-mapping
  size: 11101
  timestamp: 1673103208955
- kind: conda
  name: ipykernel
  version: 6.29.4
@@ -1715,9 +1813,9 @@ packages:
  timestamp: 1713667175451
- kind: pypi
  name: plus-sync
  version: 0.1.1.dev16+g3fefaed
  version: 0.1.1.dev41+gc8966b4.d20240627
  path: .
  sha256: 8f1d713ee84a1d3ff11a12465b08061fb414547c49a19a9708ffb236b2c18bbc
  sha256: ffe7fec1ecb45d785e5651831378ba52a601a34a54898171d6b6a80f03f917a1
  requires_dist:
  - attrs
  - attrs-strict
@@ -1870,6 +1968,59 @@ packages:
  - pytest!=3.3.0,>=3.2.1 ; extra == 'tests'
  - hypothesis>=3.27.0 ; extra == 'tests'
  requires_python: '>=3.6'
- kind: conda
  name: pytest
  version: 8.2.2
  build: pyhd8ed1ab_0
  subdir: noarch
  noarch: python
  url: https://conda.anaconda.org/conda-forge/noarch/pytest-8.2.2-pyhd8ed1ab_0.conda
  sha256: 00b7a49b31cf705b59edbd96219d8a67d2b9f51a913aa059fadd921b016965cb
  md5: 0f3f49c22c7ef3a1195fa61dad3c43be
  depends:
  - colorama
  - exceptiongroup >=1.0.0rc8
  - iniconfig
  - packaging
  - pluggy <2.0,>=1.5
  - python >=3.8
  - tomli >=1
  constrains:
  - pytest-faulthandler >=2
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/pytest?source=conda-forge-mapping
  size: 257061
  timestamp: 1717533913269
- kind: conda
  name: pytest-cov
  version: 5.0.0
  build: pyhd8ed1ab_0
  subdir: noarch
  noarch: python
  url: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-5.0.0-pyhd8ed1ab_0.conda
  sha256: 218306243faf3c36347131c2b36bb189daa948ac2e92c7ab52bb26cc8c157b3c
  md5: c54c0107057d67ddf077751339ec2c63
  depends:
  - coverage >=5.2.1
  - pytest >=4.6
  - python >=3.8
  - toml
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/pytest-cov?source=conda-forge-mapping
  size: 25507
  timestamp: 1711411153367
- kind: pypi
  name: pytest-sftpserver
  version: 1.3.0
  url: https://files.pythonhosted.org/packages/5c/07/a66ce67849514133361887636e0ca187e894bca241686adedd414a06cb50/pytest_sftpserver-1.3.0-py2.py3-none-any.whl
  sha256: c5e8a37049866d4eabc711db9f1c09e1c02ab72ba290f5fd244939c9a188042f
  requires_dist:
  - paramiko
  - six
- kind: conda
  name: python
  version: 3.12.3
@@ -2216,6 +2367,23 @@ packages:
  purls: []
  size: 3318875
  timestamp: 1699202167581
- kind: conda
  name: toml
  version: 0.10.2
  build: pyhd8ed1ab_0
  subdir: noarch
  noarch: python
  url: https://conda.anaconda.org/conda-forge/noarch/toml-0.10.2-pyhd8ed1ab_0.tar.bz2
  sha256: f0f3d697349d6580e4c2f35ba9ce05c65dc34f9f049e85e45da03800b46139c1
  md5: f832c45a477c78bebd107098db465095
  depends:
  - python >=2.7
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/toml?source=conda-forge-mapping
  size: 18433
  timestamp: 1604308660817
- kind: conda
  name: tomli
  version: 2.0.1
Loading