Skip to content

Commit

Permalink
Change label names
Browse files Browse the repository at this point in the history
  • Loading branch information
bstrausser committed Apr 10, 2024
1 parent a8aa60c commit 138a5a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions core/testcontainers/core/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from testcontainers.core.config import RYUK_IMAGE

SESSION_ID: str = str(uuid4())
TEST_CONTAINERS_NAMESPACE = "org.testcontainers"
TESTCONTAINERS_NAMESPACE = "org.testcontainers"

LABEL_TEST_CONTAINERS = TEST_CONTAINERS_NAMESPACE
LABEL_TESTCONTAINERS = TESTCONTAINERS_NAMESPACE
LABEL_SESSION_ID = "org.testcontainers.session-id"
LABEL_VERSION = "org.testcontainers.version"
LABEL_LANG = "org.testcontainers.lang"
Expand All @@ -18,11 +18,11 @@ def create_labels(image: str, labels: Optional[dict[str, str]]) -> dict[str, str
labels = {}
else:
for k in labels:
if k.startswith(TEST_CONTAINERS_NAMESPACE):
if k.startswith(TESTCONTAINERS_NAMESPACE):
raise ValueError("The org.testcontainers namespace is reserved for interal use")

labels[LABEL_LANG] = "python"
labels[LABEL_TEST_CONTAINERS] = "true"
labels[LABEL_TESTCONTAINERS] = "true"
labels[LABEL_VERSION] = importlib.metadata.version("testcontainers")

if image == RYUK_IMAGE:
Expand Down
8 changes: 4 additions & 4 deletions core/tests/test_labels.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from testcontainers.core.labels import (
LABEL_LANG,
LABEL_SESSION_ID,
LABEL_TEST_CONTAINERS,
LABEL_TESTCONTAINERS,
LABEL_VERSION,
create_labels,
TEST_CONTAINERS_NAMESPACE,
TESTCONTAINERS_NAMESPACE,
)
import pytest
from testcontainers.core.config import RYUK_IMAGE
Expand All @@ -18,7 +18,7 @@ def assert_in_with_value(labels: dict, label: str, value: str, known_before_test

testdata = [
(LABEL_LANG, "python", True),
(LABEL_TEST_CONTAINERS, "true", True),
(LABEL_TESTCONTAINERS, "true", True),
(LABEL_SESSION_ID, "some", False),
(LABEL_VERSION, "some", False),
]
Expand All @@ -33,7 +33,7 @@ def test_containers_creates_expected_labels(label, value, known_before_test_time
def test_containers_throws_on_namespace_collision():

with pytest.raises(ValueError):
create_labels("not-ryuk", {TEST_CONTAINERS_NAMESPACE: "fake"})
create_labels("not-ryuk", {TESTCONTAINERS_NAMESPACE: "fake"})


def test_containers_respect_custom_labels_if_no_collision():
Expand Down

0 comments on commit 138a5a9

Please # to comment.