From c5220944d2acdb912c129fc82ac8a83d24e9845d Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Thu, 30 Sep 2021 22:17:28 +0800 Subject: Static: variables in the "share" option. This commit supports variable in the "share" option, the finding path to file serve is the value from "share". An example: { "share": "/www/data/static$uri" } --- test/test_static_mount.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/test_static_mount.py') diff --git a/test/test_static_mount.py b/test/test_static_mount.py index 570f6439..fb4fbe4b 100644 --- a/test/test_static_mount.py +++ b/test/test_static_mount.py @@ -44,7 +44,7 @@ class TestStaticMount(TestApplicationProto): self._load_conf( { "listeners": {"*:7080": {"pass": "routes"}}, - "routes": [{"action": {"share": temp_dir + "/assets/dir"}}], + "routes": [{"action": {"share": temp_dir + "/assets/dir$uri"}}], } ) @@ -72,14 +72,14 @@ class TestStaticMount(TestApplicationProto): assert resp['body'] == 'mount' assert 'success' in self.conf( - {"share": temp_dir + "/assets/dir", "traverse_mounts": False}, + {"share": temp_dir + "/assets/dir$uri", "traverse_mounts": False}, 'routes/0/action', ), 'configure mount disable' assert self.get(url='/mount/')['status'] == 403 assert 'success' in self.conf( - {"share": temp_dir + "/assets/dir", "traverse_mounts": True}, + {"share": temp_dir + "/assets/dir$uri", "traverse_mounts": True}, 'routes/0/action', ), 'configure mount enable' @@ -97,14 +97,14 @@ class TestStaticMount(TestApplicationProto): { "match": {"method": "HEAD"}, "action": { - "share": temp_dir + "/assets/dir", + "share": temp_dir + "/assets/dir$uri", "traverse_mounts": False, }, }, { "match": {"method": "GET"}, "action": { - "share": temp_dir + "/assets/dir", + "share": temp_dir + "/assets/dir$uri", "traverse_mounts": True, }, }, @@ -120,7 +120,7 @@ class TestStaticMount(TestApplicationProto): assert 'success' in self.conf( { - "share": temp_dir + "/assets/dir", + "share": temp_dir + "/assets/dir$uri", "chroot": temp_dir + "/assets", }, 'routes/0/action', @@ -130,7 +130,7 @@ class TestStaticMount(TestApplicationProto): assert 'success' in self.conf( { - "share": temp_dir + "/assets/dir", + "share": temp_dir + "/assets/dir$uri", "chroot": temp_dir + "/assets", "traverse_mounts": False, }, -- cgit From 39adb292d54403d17f86f6852e87b0bda1d49946 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Mon, 18 Oct 2021 01:10:11 +0100 Subject: Tests: style. --- test/test_static_mount.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test/test_static_mount.py') diff --git a/test/test_static_mount.py b/test/test_static_mount.py index fb4fbe4b..e34a8a07 100644 --- a/test/test_static_mount.py +++ b/test/test_static_mount.py @@ -3,7 +3,6 @@ import subprocess from pathlib import Path import pytest - from unit.applications.proto import TestApplicationProto -- cgit From ae035852385032cc6c502c0e560fc682cacdbf34 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Mon, 15 Nov 2021 12:13:54 +0000 Subject: Tests: refactored working with processes. --- test/test_static_mount.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'test/test_static_mount.py') diff --git a/test/test_static_mount.py b/test/test_static_mount.py index e34a8a07..82eda956 100644 --- a/test/test_static_mount.py +++ b/test/test_static_mount.py @@ -22,7 +22,7 @@ class TestStaticMount(TestApplicationProto): Path(temp_dir + '/assets/mount/index.html').write_text('mount') try: - process = subprocess.Popen( + subprocess.check_output( [ "mount", "--bind", @@ -32,35 +32,33 @@ class TestStaticMount(TestApplicationProto): stderr=subprocess.STDOUT, ) - process.communicate() - except KeyboardInterrupt: raise - except: + except subprocess.CalledProcessError: pytest.fail('Can\'t run mount process.') self._load_conf( { "listeners": {"*:7080": {"pass": "routes"}}, - "routes": [{"action": {"share": temp_dir + "/assets/dir$uri"}}], + "routes": [ + {"action": {"share": temp_dir + "/assets/dir$uri"}} + ], } ) yield try: - process = subprocess.Popen( + subprocess.check_output( ["umount", "--lazy", temp_dir + "/assets/dir/mount"], stderr=subprocess.STDOUT, ) - process.communicate() - except KeyboardInterrupt: raise - except: + except subprocess.CalledProcessError: pytest.fail('Can\'t run umount process.') def test_static_mount(self, temp_dir, skip_alert): -- cgit