Skip to content

Commit 562aa88

Browse files
committed
feat: mock environment variables in tests and update SYMBOL_VERSION type to string
1 parent 4e2e029 commit 562aa88

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

sources/graphics_chart_drawer_test.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,27 @@
33

44
import pytest
55

6+
# Mock environment variables before importing the modules
7+
os.environ["INPUT_GH_TOKEN"] = "mock_gh_token"
8+
os.environ["INPUT_WAKATIME_API_KEY"] = "mock_wakatime_key"
9+
10+
611
# Import the function and constants we're testing
7-
from graphics_chart_drawer import GRAPH_PATH, MAX_LANGUAGES, create_loc_graph
12+
from graphics_chart_drawer import MAX_LANGUAGES # noqa: E402
13+
from graphics_chart_drawer import GRAPH_PATH, create_loc_graph # noqa: E402
14+
15+
16+
@pytest.fixture(autouse=True)
17+
def mock_environment():
18+
"""Fixture to ensure environment variables are set for all tests"""
19+
with patch.dict(
20+
os.environ,
21+
{
22+
"INPUT_GH_TOKEN": "mock_gh_token",
23+
"INPUT_WAKATIME_API_KEY": "mock_wakatime_key",
24+
},
25+
):
26+
yield
827

928

1029
@pytest.fixture

sources/manager_environment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from os import getenv, environ
1+
from os import environ, getenv
22

33

44
class EnvironmentManager:
@@ -48,7 +48,7 @@ class EnvironmentManager:
4848
LOCALE = getenv("INPUT_LOCALE", "en")
4949
UPDATED_DATE_FORMAT = getenv("INPUT_UPDATED_DATE_FORMAT", "%d/%m/%Y %H:%M:%S")
5050
IGNORED_REPOS = getenv("INPUT_IGNORED_REPOS", "").replace(" ", "").split(",")
51-
SYMBOL_VERSION = int(getenv("INPUT_SYMBOL_VERSION"))
51+
SYMBOL_VERSION = getenv("INPUT_SYMBOL_VERSION", "1")
5252

5353
DEBUG_LOGGING = getenv("INPUT_DEBUG_LOGGING", "0").lower() in _TRUTHY
5454
DEBUG_RUN = getenv("DEBUG_RUN", "False").lower() in _TRUTHY

sources/manager_environment_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def test_list_variable(env_manager):
2929
assert isinstance(env_manager.IGNORED_REPOS, list)
3030

3131

32-
def test_integer_variable(env_manager):
33-
assert isinstance(env_manager.SYMBOL_VERSION, int)
32+
def test_string_variable(env_manager):
33+
assert isinstance(env_manager.SYMBOL_VERSION, str)
3434

3535

3636
def test_debugging_variables(env_manager):

0 commit comments

Comments
 (0)