diff --git a/testsuite/datmantests/test_backup_and_extract.py b/testsuite/datmantests/test_backup_and_extract.py index 78b1472..a6cd012 100644 --- a/testsuite/datmantests/test_backup_and_extract.py +++ b/testsuite/datmantests/test_backup_and_extract.py @@ -33,6 +33,16 @@ class TestBackupAndExtract(TestCase): print("extracting") dest_path = tdpath.joinpath("desta") - subprocess.check_call(("datman", "extract", "--skip-metadata", "--accept-partial", "main", "../desta"), cwd=datman_path) + subprocess.check_call( + ( + "datman", + "extract", + "--skip-metadata", + "--accept-partial", + "main", + "../desta", + ), + cwd=datman_path, + ) - time.sleep(300) \ No newline at end of file + time.sleep(300) diff --git a/testsuite/helpers/__init__.py b/testsuite/helpers/__init__.py index f3924c2..d5b092e 100644 --- a/testsuite/helpers/__init__.py +++ b/testsuite/helpers/__init__.py @@ -2,7 +2,7 @@ import os.path from hashlib import sha256 from pathlib import Path from random import Random -from typing import Union, Tuple +from typing import Tuple, Union import attr from immutabledict import immutabledict @@ -46,7 +46,7 @@ def generate_random_file(rng: Random, path: Path) -> FileDescriptor: sha256_hasher = sha256() - with path.open('wb') as file: + with path.open("wb") as file: while bytes_to_gen > CHUNK_SIZE: next_bytes = rng.randbytes(CHUNK_SIZE) file.write(next_bytes) @@ -64,13 +64,16 @@ def generate_random_file(rng: Random, path: Path) -> FileDescriptor: file_stat.st_mtime_ns // 1000000, file_stat.st_mode, file_stat.st_uid, - file_stat.st_gid + file_stat.st_gid, ) -def generate_random_dir(rng: Random, path: Path, max_remaining_files: int) -> Tuple[DirectoryDescriptor, int]: +def generate_random_dir( + rng: Random, path: Path, max_remaining_files: int +) -> Tuple[DirectoryDescriptor, int]: """ - Generates a random directory at the given path, and returns its descriptor (and the remaining number of files allowed). + Generates a random directory at the given path, and returns its descriptor + (and the remaining number of files allowed). :param rng: PRNG to use :param path: path to use :param max_remaining_files: The maximum number of files allowed. @@ -92,17 +95,22 @@ def generate_random_dir(rng: Random, path: Path, max_remaining_files: int) -> Tu if is_file: contents[filename] = generate_random_file(rng, filepath) else: - contents[filename], max_remaining_files = generate_random_dir(rng, filepath, max_remaining_files) + contents[filename], max_remaining_files = generate_random_dir( + rng, filepath, max_remaining_files + ) file_stat = os.stat(path) - return DirectoryDescriptor( - immutabledict(contents), - file_stat.st_mtime_ns // 1000000, - file_stat.st_mode, - file_stat.st_uid, - file_stat.st_gid - ), max_remaining_files + return ( + DirectoryDescriptor( + immutabledict(contents), + file_stat.st_mtime_ns // 1000000, + file_stat.st_mode, + file_stat.st_uid, + file_stat.st_gid, + ), + max_remaining_files, + ) def scan_file(path: Path) -> FileDescriptor: @@ -121,7 +129,7 @@ def scan_file(path: Path) -> FileDescriptor: file_stat.st_mtime_ns // 1000000, file_stat.st_mode, file_stat.st_uid, - file_stat.st_gid + file_stat.st_gid, ) @@ -129,7 +137,7 @@ def scan_dir(path: Path) -> DirectoryDescriptor: contents = dict() for entry in os.scandir(path): name = entry.name - if name in ('.', '..'): + if name in (".", ".."): continue filepath = path.joinpath(name) if filepath.is_dir(): @@ -145,5 +153,5 @@ def scan_dir(path: Path) -> DirectoryDescriptor: file_stat.st_mtime_ns // 1000000, file_stat.st_mode, file_stat.st_uid, - file_stat.st_gid + file_stat.st_gid, ) diff --git a/testsuite/helpers/datman_helpers.py b/testsuite/helpers/datman_helpers.py index 4c4f3f3..cb7c8c8 100644 --- a/testsuite/helpers/datman_helpers.py +++ b/testsuite/helpers/datman_helpers.py @@ -11,7 +11,8 @@ def set_up_simple_datman(path: Path): subprocess.check_call(("datman", "init"), cwd=path) with path.joinpath("datman.toml").open("a") as file: - file.write(f""" + file.write( + f""" [source.srca] directory = "{path.joinpath("srca")}" hostname = "{get_hostname()}" @@ -19,4 +20,5 @@ hostname = "{get_hostname()}" [piles.main] path = "main" included_labels = ["precious"] - """) + """ + ) diff --git a/testsuite/helpers/yama_helpers.py b/testsuite/helpers/yama_helpers.py index 80d314f..315c11a 100644 --- a/testsuite/helpers/yama_helpers.py +++ b/testsuite/helpers/yama_helpers.py @@ -6,4 +6,4 @@ from pathlib import Path def set_up_simple_yama(path: Path): path.mkdir(exist_ok=True) subprocess.check_call(("yama", "init"), cwd=path) - shutil.copyfile("../example_zstd.dict", path.joinpath("important_zstd.dict")) \ No newline at end of file + shutil.copyfile("../example_zstd.dict", path.joinpath("important_zstd.dict")) diff --git a/testsuite/scripts-dev/lint.sh b/testsuite/scripts-dev/lint.sh new file mode 100755 index 0000000..bfbe962 --- /dev/null +++ b/testsuite/scripts-dev/lint.sh @@ -0,0 +1,18 @@ +#!/bin/sh -eu + +if [ $# -ge 1 ] +then + files=$* +else + files="setup.py datmantests helpers yamatests" +fi + +echo "Linting these locations: $files" +echo " ===== Running isort ===== " +isort $files +echo " ===== Running black ===== " +black $files +echo " ===== Running flake8 ===== " +flake8 $files +#echo " ===== Running mypy ===== " +#mypy $files diff --git a/testsuite/setup.cfg b/testsuite/setup.cfg new file mode 100644 index 0000000..549f8ad --- /dev/null +++ b/testsuite/setup.cfg @@ -0,0 +1,21 @@ +[flake8] +# line length defaulted to by black +max-line-length = 88 + +# see https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes +# for error codes. The ones we ignore are: +# W503: line break before binary operator +# W504: line break after binary operator +# E203: whitespace before ':' (which is contrary to pep8?) +# (this is a subset of those ignored in Synapse) +ignore=W503,W504,E203 + +[isort] +line_length = 88 +sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,TESTS,LOCALFOLDER +default_section=THIRDPARTY +known_first_party=scone +known_tests=tests +multi_line_output=3 +include_trailing_comma=true +combine_as_imports=true diff --git a/testsuite/setup.py b/testsuite/setup.py index 8ca05cc..cd07068 100644 --- a/testsuite/setup.py +++ b/testsuite/setup.py @@ -6,7 +6,7 @@ import os import sys from shutil import rmtree -from setuptools import find_packages, setup, Command +from setuptools import Command, find_packages, setup # Package meta-data. NAME = "yamadatmantestsuite" @@ -18,21 +18,11 @@ REQUIRES_PYTHON = ">=3.9.0" VERSION = "0.0.0" # What packages are required for this module to be executed? -REQUIRED = [ - "green", - "attrs", - "immutabledict" -] +REQUIRED = ["green", "attrs", "immutabledict"] # What packages are optional? -EXTRAS = { - "dev": [ - "black==21.7b0", - "flake8==3.9.2", - "isort==5.9.2" - ] -} +EXTRAS = {"dev": ["black==21.7b0", "flake8==3.9.2", "isort==5.9.2"]} # The rest you shouldn't have to touch too much :) # ------------------------------------------------ diff --git a/testsuite/yamatests/test_store_and_retrieve.py b/testsuite/yamatests/test_store_and_retrieve.py index 7155edc..b544e32 100644 --- a/testsuite/yamatests/test_store_and_retrieve.py +++ b/testsuite/yamatests/test_store_and_retrieve.py @@ -1,6 +1,3 @@ -from unittest import TestCase - - # class TestStoreAndRetrieve(TestCase): # def test_store_and_retrieve(self): -# \ No newline at end of file +#