diff --git a/.gitignore b/.gitignore index e395bb1..5a2134f 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,5 @@ helpers-results /.mypy_cache/ .coverage .mypy_cache -test/tmp \ No newline at end of file +test/tmp +test/nextcloud_pwd.mdp \ No newline at end of file diff --git a/test/test_datasync.py b/test/test_datasync.py index 7212d23..5a280d5 100644 --- a/test/test_datasync.py +++ b/test/test_datasync.py @@ -10,9 +10,12 @@ import unittest from os import chdir, path as os_path from pathlib import Path import pprint +import os +import glob from io import StringIO from contextlib import redirect_stdout, redirect_stderr import shutil +import json from contexttimer import Timer print(__name__) @@ -32,7 +35,28 @@ class TestDabDataSync(unittest.TestCase): shutil.rmtree(testdir_path / "test_data2", ignore_errors=True) shutil.copytree(testdir_path / "test_data_origin", testdir_path / "test_data") shutil.copytree(testdir_path / "test_data_origin", testdir_path / "test_data2") - + + nextcloud_pwd="" + if 'nextcloud_pwd' in os.environ: + nextcloud_pwd = os.environ.get("nextcloud_pwd") + elif os.path.isfile(testdir_path / "nextcloud_pwd.mdp"): + with open(testdir_path / "nextcloud_pwd.mdp","rt",encoding="utf-8") as pwd_file: + nextcloud_pwd=pwd_file.read() + else: + raise RuntimeError("NextCloud pwd file not found") + files = glob.glob(str(testdir_path / "test_data" / "*.json")) + files += glob.glob(str(testdir_path / "test_data2" / "*.json")) + for file in files: + with open(file) as f: + data = json.load(f) + try: + data["Args"]["FSSync_NextCloud_Password"]["value"] = nextcloud_pwd + except Exception as exc: + print(f"ignoring exception: {exc}") + os.remove(file) + with open(file, 'w') as f: + json.dump(data, f) + def tearDown(self) -> None: shutil.rmtree(testdir_path / "test_data", ignore_errors=True) shutil.rmtree(testdir_path / "test_data2", ignore_errors=True) diff --git a/test/test_manifest_nextcloud.json b/test/test_manifest_nextcloud.json index 1fea9ae..92bda2c 100644 --- a/test/test_manifest_nextcloud.json +++ b/test/test_manifest_nextcloud.json @@ -254,7 +254,7 @@ }, "FSSync_NextCloud_Password": { "type": "STRING", - "value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE" + "value": "" }, "FSSync_NextCloud_Path": { "type": "STRING", diff --git a/test/test_manifest_nextcloud_disabled.json b/test/test_manifest_nextcloud_disabled.json index 7395f41..ebca5fc 100644 --- a/test/test_manifest_nextcloud_disabled.json +++ b/test/test_manifest_nextcloud_disabled.json @@ -4,6 +4,6 @@ "FSSync_NextCloud_Enabled": {"type": "BOOL", "value": false}, "FSSync_NextCloud_Address": {"type": "URL", "value": "https://chacha.ddns.net/nextcloud"}, "FSSync_NextCloud_User": {"type": "STRING", "value": "chacha-bot"}, -"FSSync_NextCloud_Password": {"type": "STRING", "value": "F3P8m-nQHik-NSmb2-mnFEF-s85RE"}, +"FSSync_NextCloud_Password": {"type": "STRING", "value": ""}, "FSSync_NextCloud_Path": {"type": "STRING", "value": "pydabfactory"} }} \ No newline at end of file