This commit is contained in:
@@ -8,8 +8,11 @@ from photools3.metadata_writer import (
|
||||
_is_prefixed,
|
||||
_prefixed,
|
||||
)
|
||||
from photools3.settings import settings
|
||||
from test.test_photo import PATHS_DNG_EXAMPLES
|
||||
|
||||
PREFIX = settings.metadata_prefix
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def make_dng_file(tmp_path):
|
||||
@@ -74,13 +77,13 @@ def test_get_keywords(make_dng_file, pic, expected_keywords):
|
||||
def test_prefixed():
|
||||
txt = "bla_bla"
|
||||
txt_prefixed = _prefixed(txt)
|
||||
assert txt_prefixed == "photools|bla_bla"
|
||||
assert txt_prefixed == f"{PREFIX}bla_bla"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"txt, expected_result",
|
||||
[
|
||||
("photools|some text", True),
|
||||
(f"{PREFIX}some text", True),
|
||||
("prefix is missing here", False),
|
||||
("some_perfix|but not the right one", False),
|
||||
],
|
||||
@@ -108,7 +111,7 @@ def test_set_caption(make_dng_file, pic):
|
||||
assert metadata_writer.sidecar_path.exists() # ... but now!
|
||||
result = metadata_writer.get_caption()
|
||||
assert result
|
||||
assert result == "photools|This is a test"
|
||||
assert result == f"{PREFIX}This is a test"
|
||||
|
||||
|
||||
def test_set_caption_on_existing(metadata_writer_on_existing):
|
||||
@@ -120,19 +123,19 @@ def test_set_caption_on_existing(metadata_writer_on_existing):
|
||||
metadata_writer_on_existing.write_caption("Another caption")
|
||||
assert (
|
||||
metadata_writer_on_existing.get_caption()
|
||||
== "Let's pretend this is the caption of the original image. photools|Another caption"
|
||||
== f"Let's pretend this is the caption of the original image. {PREFIX}Another caption"
|
||||
)
|
||||
|
||||
metadata_writer_on_existing.write_caption("Updated caption")
|
||||
assert (
|
||||
metadata_writer_on_existing.get_caption()
|
||||
== "Let's pretend this is the caption of the original image. photools|Updated caption"
|
||||
== f"Let's pretend this is the caption of the original image. {PREFIX}Updated caption"
|
||||
)
|
||||
|
||||
metadata_writer_on_existing.write_caption("Don't do this!", override=False)
|
||||
assert (
|
||||
metadata_writer_on_existing.get_caption()
|
||||
== "Let's pretend this is the caption of the original image. photools|Updated caption"
|
||||
== f"Let's pretend this is the caption of the original image. {PREFIX}Updated caption"
|
||||
)
|
||||
|
||||
|
||||
@@ -144,23 +147,23 @@ def test_set_caption_on_existing(metadata_writer_on_existing):
|
||||
[
|
||||
"architektur",
|
||||
"zeit|abend",
|
||||
"photools|hund",
|
||||
"photools|katze",
|
||||
"photools|maus",
|
||||
f"{PREFIX}hund",
|
||||
f"{PREFIX}katze",
|
||||
f"{PREFIX}maus",
|
||||
],
|
||||
),
|
||||
(
|
||||
PATHS_DNG_EXAMPLES[1],
|
||||
["architektur", "photools|hund", "photools|katze", "photools|maus"],
|
||||
["architektur", f"{PREFIX}hund", f"{PREFIX}katze", f"{PREFIX}maus"],
|
||||
),
|
||||
(
|
||||
PATHS_DNG_EXAMPLES[2],
|
||||
[
|
||||
"morgen",
|
||||
"tiere|vögel",
|
||||
"photools|hund",
|
||||
"photools|katze",
|
||||
"photools|maus",
|
||||
f"{PREFIX}hund",
|
||||
f"{PREFIX}katze",
|
||||
f"{PREFIX}maus",
|
||||
],
|
||||
),
|
||||
(
|
||||
@@ -173,9 +176,9 @@ def test_set_caption_on_existing(metadata_writer_on_existing):
|
||||
"mainz",
|
||||
"spiegelung",
|
||||
"wasser",
|
||||
"photools|hund",
|
||||
"photools|katze",
|
||||
"photools|maus",
|
||||
f"{PREFIX}hund",
|
||||
f"{PREFIX}katze",
|
||||
f"{PREFIX}maus",
|
||||
],
|
||||
),
|
||||
(
|
||||
@@ -187,9 +190,9 @@ def test_set_caption_on_existing(metadata_writer_on_existing):
|
||||
"personen",
|
||||
"tiefe",
|
||||
"weg",
|
||||
"photools|hund",
|
||||
"photools|katze",
|
||||
"photools|maus",
|
||||
f"{PREFIX}hund",
|
||||
f"{PREFIX}katze",
|
||||
f"{PREFIX}maus",
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -200,9 +203,9 @@ def test_set_keywords(make_dng_file, pic, expected_keywords):
|
||||
result = metadata_writer.get_keywords()
|
||||
assert result
|
||||
assert isinstance(result, list)
|
||||
assert "photools|hund" in result
|
||||
assert "photools|katze" in result
|
||||
assert "photools|maus" in result
|
||||
assert f"{PREFIX}hund" in result
|
||||
assert f"{PREFIX}katze" in result
|
||||
assert f"{PREFIX}maus" in result
|
||||
|
||||
|
||||
def test_set_keywords_on_existing():
|
||||
|
||||
Reference in New Issue
Block a user