From f6113c7454d9fa09415aab38dc8a83195d449a1e Mon Sep 17 00:00:00 2001 From: Gideon Schoonbee Date: Fri, 28 Oct 2022 15:27:15 +0200 Subject: [PATCH] - Fixed a problem where the package was not imported correctly. (#7) - Fixed a problem where the package was not imported correctly. - Fixed a problem where the tests were not comparing config data correctly and failing. - Update the readme. - Renamed the base package. - Updated some dependencies. - Fixed a failed linting test. - Fixed a failing test suite where the import was not done correctly. --- .github/workflows/master.yml | 2 +- Makefile | 2 +- README.md | 10 ++++------ {src => backup}/__init__.py | 0 {src => backup}/backup.py | 9 +++++---- {src => backup}/config.yaml.example | 0 {src => backup}/data_classes.py | 0 {src => backup}/exceptions.py | 0 requirements.in | 7 ++++--- requirements.txt | 20 +++++++++++--------- setup.cfg | 8 ++++---- tests/test_backup.py | 6 +++--- 12 files changed, 33 insertions(+), 31 deletions(-) rename {src => backup}/__init__.py (100%) rename {src => backup}/backup.py (96%) rename {src => backup}/config.yaml.example (100%) rename {src => backup}/data_classes.py (100%) rename {src => backup}/exceptions.py (100%) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 276da5a..7673bbb 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -33,7 +33,7 @@ jobs: pip install -e . - name: Lint With flake8 run: | - flake8 src/ + flake8 backup/ - name: Test With PyTest run: | pytest tests/ diff --git a/Makefile b/Makefile index 91f55d2..a6561e2 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ test: ## Run UNIT and Functional Tests with PyTest. pytest tests --cov -s lint: ## Run a code style linter (flake8) over the app code. - flake8 src/ + flake8 backup/ clean: find . -name '.coverage' -delete diff --git a/README.md b/README.md index 00cdfeb..6441987 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Rsync Backup Automation - - This is a small abstraction on the RSYNC command found on Unix or Linux to automate some repetitive things you have to do when creating complex backups between two Unix or Linux systems with encryption. @@ -119,7 +117,7 @@ From the root of the project folder run the following to get the help printout of how to use the script. ```commandline -python ./src/backup.py --help +python ./backup/backup.py --help ``` ```commandline usage: Backup Remote Files. [-h] [-j JOB] [-s] [-c CONFIG] [-d] @@ -136,14 +134,14 @@ options: ### Run A Job -When you are setup you can run the job with the following command. +When you are set up you can run the job with the following command. ```commandline -python ./src/backup.py -j offsite_1 +python ./backup/backup.py -j offsite_1 ``` or, if not inside VENV ```commandline -python3 ./src/backup.py -j offsite_1 +python3 ./backup/backup.py -j offsite_1 ``` You can also simulate the job with a "dry run", to make sure everything diff --git a/src/__init__.py b/backup/__init__.py similarity index 100% rename from src/__init__.py rename to backup/__init__.py diff --git a/src/backup.py b/backup/backup.py similarity index 96% rename from src/backup.py rename to backup/backup.py index 75b0405..155bb59 100755 --- a/src/backup.py +++ b/backup/backup.py @@ -13,10 +13,11 @@ import time import yaml from termcolor import cprint -from src.data_classes import ConfigDataClass, ConfigListDataClass -from src.exceptions import (PathValidationException, PathNotFoundException, - RemoteSocketNotFoundException, - ConfigJobNotFoundException, RsyncNotFoundException) +from data_classes import ConfigDataClass, ConfigListDataClass +from exceptions import (PathValidationException, PathNotFoundException, + RemoteSocketNotFoundException, + ConfigJobNotFoundException, + RsyncNotFoundException) RSYNC_VERSION = '2.6.9' DEFAULT_CONFIG = 'config.yaml' diff --git a/src/config.yaml.example b/backup/config.yaml.example similarity index 100% rename from src/config.yaml.example rename to backup/config.yaml.example diff --git a/src/data_classes.py b/backup/data_classes.py similarity index 100% rename from src/data_classes.py rename to backup/data_classes.py diff --git a/src/exceptions.py b/backup/exceptions.py similarity index 100% rename from src/exceptions.py rename to backup/exceptions.py diff --git a/requirements.in b/requirements.in index a06b46b..a317b4f 100644 --- a/requirements.in +++ b/requirements.in @@ -1,7 +1,8 @@ flake8==5.0.4 -pip-tools==6.8.0 +pip-tools==6.9.0 termcolor==2.0.1 -pytest==7.1.3 -pytest-cov==3.0.0 +pytest==7.2.0 +pytest-cov==4.0.0 pytest-mock==3.10.0 pyyaml==6.0 +build==0.9.0 diff --git a/requirements.txt b/requirements.txt index 90f2c8f..5bd5844 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,21 @@ # -# This file is autogenerated by pip-compile with python 3.10 +# This file is autogenerated by pip-compile with python 3.9 # To update, run: # # pip-compile # attrs==22.1.0 # via pytest -build==0.8.0 - # via pip-tools +build==0.9.0 + # via + # -r requirements.in + # pip-tools click==8.1.3 # via pip-tools -coverage[toml]==6.4.4 +coverage[toml]==6.5.0 # via pytest-cov +exceptiongroup==1.0.0 + # via pytest flake8==5.0.4 # via -r requirements.in iniconfig==1.1.1 @@ -24,24 +28,22 @@ packaging==21.3 # pytest pep517==0.13.0 # via build -pip-tools==6.8.0 +pip-tools==6.9.0 # via -r requirements.in pluggy==1.0.0 # via pytest -py==1.11.0 - # via pytest pycodestyle==2.9.1 # via flake8 pyflakes==2.5.0 # via flake8 pyparsing==3.0.9 # via packaging -pytest==7.1.3 +pytest==7.2.0 # via # -r requirements.in # pytest-cov # pytest-mock -pytest-cov==3.0.0 +pytest-cov==4.0.0 # via -r requirements.in pytest-mock==3.10.0 # via -r requirements.in diff --git a/setup.cfg b/setup.cfg index 9d26dfb..70ccbb2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,8 +2,8 @@ [metadata] -name = RSYNC Backup Automation -version = 2.0.1 +name = backup +version = 2.1.0 author = Mortolian maintainer = Mortolian keywords = rsync, backup, sync, ssh @@ -14,7 +14,7 @@ classifiers = [options] package_dir = - =src + =backup packages = find: install_requires = file:requirements.txt zip_safe = False @@ -22,7 +22,7 @@ python_requires = >=3.8 [options.packages.find] -where = src +where = backup [flake8] diff --git a/tests/test_backup.py b/tests/test_backup.py index 04aec34..425fb94 100644 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -1,8 +1,8 @@ import subprocess import pytest import socket -from src import backup -from src.data_classes import ConfigDataClass, ConfigListDataClass +from backup import backup +from backup.data_classes import ConfigListDataClass, ConfigDataClass BAD_CONFIG_FILE = """ offsite_1:: @@ -86,7 +86,7 @@ def mock_config_bad_file(mocker): def test_read_config(mock_config_good_file) -> None: result = backup.readConfig(config_file_path='mock_file.yaml') - assert result == CONFIG_DATA_OBJECT + assert repr(result) == repr(CONFIG_DATA_OBJECT) def test_read_config_key_error(mock_config_bad_file) -> None: