fix: remove extra quote when executing a note indexation and update deps
This commit is contained in:
parent
5908a70691
commit
67595b3220
11 changed files with 228 additions and 305 deletions
|
|
@ -29,6 +29,7 @@ def notes(notebooks_path: Path):
|
|||
dt = dt.subtract(days=day_offset)
|
||||
(dailies / f"{dt.date()}.age").touch()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def unencrypted_notes(notebooks_path):
|
||||
unencrypted_root_path = notebooks_path / "unencrypted"
|
||||
|
|
|
|||
|
|
@ -4,15 +4,18 @@ from pathlib import Path
|
|||
from halig.commands.import_unencrypted import ImportCommand
|
||||
from halig.encryption import Encryptor
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def command(settings) -> ImportCommand:
|
||||
return ImportCommand(settings)
|
||||
|
||||
|
||||
def test_get_importables(unencrypted_notes: Path, command: ImportCommand):
|
||||
notes = list(command.get_importables())
|
||||
assert len(notes) == 15
|
||||
assert notes == list(unencrypted_notes.glob("**/*.md"))
|
||||
|
||||
|
||||
def test_import(unencrypted_notes: Path, command: ImportCommand, encryptor: Encryptor):
|
||||
command.run()
|
||||
notes = command.get_importables()
|
||||
|
|
@ -23,11 +26,16 @@ def test_import(unencrypted_notes: Path, command: ImportCommand, encryptor: Encr
|
|||
encrypted_data = f.read()
|
||||
data = encryptor.decrypt(encrypted_data)
|
||||
if "inner" in str(note):
|
||||
assert f'sub{note.name.replace(".age", "").replace("_"," ")}' == data.decode()
|
||||
assert (
|
||||
f'sub{note.name.replace(".age", "").replace("_"," ")}' == data.decode()
|
||||
)
|
||||
else:
|
||||
assert note.name.replace(".age", "").replace("_"," ") == data.decode()
|
||||
assert note.name.replace(".age", "").replace("_", " ") == data.decode()
|
||||
|
||||
def test_import_unlink(unencrypted_notes: Path, command: ImportCommand, encryptor: Encryptor):
|
||||
|
||||
def test_import_unlink(
|
||||
unencrypted_notes: Path, command: ImportCommand, encryptor: Encryptor
|
||||
):
|
||||
command.unlink = True
|
||||
command.run()
|
||||
notes = command.get_importables()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ def reencrypt_command(settings):
|
|||
return ReencryptCommand(settings)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('notes')
|
||||
@pytest.mark.usefixtures("notes")
|
||||
def test_reencrypt(reencrypt_command):
|
||||
reencrypt_command.run()
|
||||
for note_path in reencrypt_command.traverse():
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ def test_instance_encryptor_from_age_keys(halig_path, notebooks_path):
|
|||
encryptor = Encryptor(settings)
|
||||
for identity in identities:
|
||||
assert str(identity) in [str(identity) for identity in encryptor.identities]
|
||||
assert str(identity.to_public()) in [str(recipient) for recipient in encryptor.recipients]
|
||||
assert str(identity.to_public()) in [
|
||||
str(recipient) for recipient in encryptor.recipients
|
||||
]
|
||||
|
||||
|
||||
def test_encrypt(encryptor: Encryptor, ssh_identity):
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ def exec_capture(func: Callable):
|
|||
|
||||
|
||||
def test_capture():
|
||||
def func(): return 1
|
||||
def func():
|
||||
return 1
|
||||
|
||||
assert exec_capture(func) == 1
|
||||
|
||||
|
|
@ -22,9 +23,10 @@ def test_capture_exits_with_custom_os_error(mocker):
|
|||
nonlocal exit_code
|
||||
exit_code = code
|
||||
|
||||
mocker.patch('halig.utils.sys.exit', side_effect=mock_exit)
|
||||
mocker.patch("halig.utils.sys.exit", side_effect=mock_exit)
|
||||
|
||||
def func(): raise OSError(2, "os_error_func")
|
||||
def func():
|
||||
raise OSError(2, "os_error_func")
|
||||
|
||||
exec_capture(func)
|
||||
assert exit_code == 2
|
||||
|
|
@ -37,9 +39,10 @@ def test_capture_exits_with_os_error(mocker):
|
|||
nonlocal exit_code
|
||||
exit_code = code
|
||||
|
||||
mocker.patch('halig.utils.sys.exit', side_effect=mock_exit)
|
||||
mocker.patch("halig.utils.sys.exit", side_effect=mock_exit)
|
||||
|
||||
def func(): raise OSError
|
||||
def func():
|
||||
raise OSError
|
||||
|
||||
exec_capture(func)
|
||||
assert not exit_code
|
||||
|
|
@ -52,9 +55,10 @@ def test_capture_exits_with_value_error(mocker):
|
|||
nonlocal exit_code
|
||||
exit_code = code
|
||||
|
||||
mocker.patch('halig.utils.sys.exit', side_effect=mock_exit)
|
||||
mocker.patch("halig.utils.sys.exit", side_effect=mock_exit)
|
||||
|
||||
def func(): raise ValueError("value_error_func")
|
||||
def func():
|
||||
raise ValueError("value_error_func")
|
||||
|
||||
exec_capture(func)
|
||||
assert exit_code == 1
|
||||
|
|
@ -67,9 +71,10 @@ def test_capture_exits_with_other_error(mocker):
|
|||
nonlocal exit_code
|
||||
exit_code = code
|
||||
|
||||
mocker.patch('halig.utils.sys.exit', side_effect=mock_exit)
|
||||
mocker.patch("halig.utils.sys.exit", side_effect=mock_exit)
|
||||
|
||||
def func(): raise ArithmeticError("arithmetic_error_func")
|
||||
def func():
|
||||
raise ArithmeticError("arithmetic_error_func")
|
||||
|
||||
exec_capture(func)
|
||||
assert exit_code == 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue