Skip to content

Commit

Permalink
full test_docker_auth_config
Browse files Browse the repository at this point in the history
  • Loading branch information
Tranquility2 committed Aug 24, 2024
1 parent e675a5a commit 8b7b487
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions core/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
from testcontainers.core.config import TestcontainersConfiguration as TCC
from testcontainers.core.config import TestcontainersConfiguration as TCC, _WARNINGS

from pytest import MonkeyPatch, mark, LogCaptureFixture

import logging


@mark.parametrize("docker_auth_config_env", ["key=value", ""])
@mark.parametrize("warning_dict", [{}, {"key": "value"}, {"DOCKER_AUTH_CONFIG": "TEST"}])
@mark.parametrize("warning_dict_post", [{}, {"key": "value"}, {"DOCKER_AUTH_CONFIG": "TEST"}])
def test_docker_auth_config(
caplog: LogCaptureFixture,
monkeypatch: MonkeyPatch,
docker_auth_config_env: str,
warning_dict: dict[str, str],
warning_dict_post: dict[str, str],
) -> None:
monkeypatch.setattr("testcontainers.core.config._WARNINGS", warning_dict)
monkeypatch.setenv("DOCKER_AUTH_CONFIG", docker_auth_config_env)
caplog.set_level(logging.WARNING)

def test_docker_auth_config() -> None:
config = TCC()
assert config.docker_auth_config is None
config.docker_auth_config = "value"
assert config.docker_auth_config == "value"
if not docker_auth_config_env:
assert config.docker_auth_config == ""
assert caplog.text == ""
else:
assert config.docker_auth_config == docker_auth_config_env

if "DOCKER_AUTH_CONFIG" in warning_dict:
assert warning_dict["DOCKER_AUTH_CONFIG"] in caplog.text

if warning_dict == {}:
monkeypatch.setattr("testcontainers.core.config._WARNINGS", warning_dict_post)

config.docker_auth_config = "new_value"
assert config.docker_auth_config == "new_value"


def test_tc_properties_get_tc_host() -> None:
Expand Down

0 comments on commit 8b7b487

Please sign in to comment.