fix output permissions tests
This commit is contained in:
parent
8230f88d80
commit
9f1470cf03
2 changed files with 7 additions and 5 deletions
|
@ -118,15 +118,15 @@ def chmod_file(path: str, cwd: str='.', permissions: str=OUTPUT_PERMISSIONS) ->
|
||||||
|
|
||||||
if not root.is_dir():
|
if not root.is_dir():
|
||||||
# path is just a plain file
|
# path is just a plain file
|
||||||
os.chmod(root, int(OUTPUT_PERMISSIONS, base=8))
|
os.chmod(root, int(permissions, base=8))
|
||||||
else:
|
else:
|
||||||
for subpath in Path(path).glob('**/*'):
|
for subpath in Path(path).glob('**/*'):
|
||||||
if subpath.is_dir():
|
if subpath.is_dir():
|
||||||
# directories need execute permissions to be able to list contents
|
# directories need execute permissions to be able to list contents
|
||||||
perms_with_x_allowed = OUTPUT_PERMISSIONS.replace('4', '5').replace('6', '7')
|
perms_with_x_allowed = permissions.replace('4', '5').replace('6', '7')
|
||||||
os.chmod(subpath, int(perms_with_x_allowed, base=8))
|
os.chmod(subpath, int(perms_with_x_allowed, base=8))
|
||||||
else:
|
else:
|
||||||
os.chmod(subpath, int(OUTPUT_PERMISSIONS, base=8))
|
os.chmod(subpath, int(permissions, base=8))
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
|
|
|
@ -11,6 +11,8 @@ from archivebox.config import OUTPUT_PERMISSIONS
|
||||||
|
|
||||||
from .fixtures import *
|
from .fixtures import *
|
||||||
|
|
||||||
|
DIR_PERMISSIONS = OUTPUT_PERMISSIONS.replace('6', '7').replace('4', '5')
|
||||||
|
|
||||||
def test_init(tmp_path, process):
|
def test_init(tmp_path, process):
|
||||||
assert "Initializing a new ArchiveBox" in process.stdout.decode("utf-8")
|
assert "Initializing a new ArchiveBox" in process.stdout.decode("utf-8")
|
||||||
|
|
||||||
|
@ -55,7 +57,7 @@ def test_correct_permissions_output_folder(tmp_path, process):
|
||||||
index_files = ['index.sqlite3', 'archive']
|
index_files = ['index.sqlite3', 'archive']
|
||||||
for file in index_files:
|
for file in index_files:
|
||||||
file_path = tmp_path / file
|
file_path = tmp_path / file
|
||||||
assert oct(file_path.stat().st_mode)[-3:] == OUTPUT_PERMISSIONS
|
assert oct(file_path.stat().st_mode)[-3:] in (OUTPUT_PERMISSIONS, DIR_PERMISSIONS)
|
||||||
|
|
||||||
def test_correct_permissions_add_command_results(tmp_path, process, disable_extractors_dict):
|
def test_correct_permissions_add_command_results(tmp_path, process, disable_extractors_dict):
|
||||||
os.chdir(tmp_path)
|
os.chdir(tmp_path)
|
||||||
|
@ -63,7 +65,7 @@ def test_correct_permissions_add_command_results(tmp_path, process, disable_extr
|
||||||
env=disable_extractors_dict)
|
env=disable_extractors_dict)
|
||||||
archived_item_path = list(tmp_path.glob('archive/**/*'))[0]
|
archived_item_path = list(tmp_path.glob('archive/**/*'))[0]
|
||||||
for path in archived_item_path.iterdir():
|
for path in archived_item_path.iterdir():
|
||||||
assert oct(path.stat().st_mode)[-3:] == OUTPUT_PERMISSIONS
|
assert oct(path.stat().st_mode)[-3:] in (OUTPUT_PERMISSIONS, DIR_PERMISSIONS)
|
||||||
|
|
||||||
def test_collision_urls_different_timestamps(tmp_path, process, disable_extractors_dict):
|
def test_collision_urls_different_timestamps(tmp_path, process, disable_extractors_dict):
|
||||||
os.chdir(tmp_path)
|
os.chdir(tmp_path)
|
||||||
|
|
Loading…
Reference in a new issue