Skip to content

Commit

Permalink
Create test for check_credentials_are_valid function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Bergner committed Jan 4, 2025
1 parent f09738c commit 130dc0b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import pytest

from pystatis import config, db
from pystatis import config, db, http_helper
from pystatis.db import check_credentials_are_valid


@pytest.fixture()
Expand Down Expand Up @@ -82,6 +83,19 @@ def test_setup_credentials(mocker, config_):
assert config_[db_name]["password"] == "test123!"


@pytest.mark.parametrize(
"mock_return, check_result",
[
(b'{"Status": "erfolgreich"}', True),
(b'{"Status": "fehlgeschlagen"}', False),
],
)
def test_check_credentials_are_valid(mocker, mock_return: bytes, check_result: bool):
mocker.patch.object(http_helper, "load_data", return_value=mock_return)
# Db name not important since we mock the request result anyway.
assert check_credentials_are_valid("genesis") == check_result


def test_supported_db():
db = config.get_supported_db()
assert isinstance(db, list)
Expand Down

0 comments on commit 130dc0b

Please sign in to comment.