From 38e34e7c92ee09daa04d04f1fda62458992eb476 Mon Sep 17 00:00:00 2001
From: Christoph Alt <christoph.alt@fau.de>
Date: Thu, 1 Aug 2024 16:09:41 +0200
Subject: [PATCH] fixed the test for load_config even if a .env file is present

---
 tests/test_dashboard_upload.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/tests/test_dashboard_upload.py b/tests/test_dashboard_upload.py
index 2caafef..d736919 100644
--- a/tests/test_dashboard_upload.py
+++ b/tests/test_dashboard_upload.py
@@ -4,19 +4,25 @@ from dashboards.upload import load_config_from_env
 from unittest.mock import patch
 import os
 
+
 def test_load_config_from_env():
     # Case 1: Test if function raises exception for missing GRAFANA_API_KEY
     with pytest.raises(ValueError) as e:
-        load_config_from_env(env_path=".env")
-    assert str(e.value) == "GRAFANA_API_KEY is None or not defined in the .env file"
+        load_config_from_env(env_path="")
+    assert str(
+        e.value) == "GRAFANA_API_KEY is None or not defined in the .env file"
 
     # Case 2: Test if function raises exception for missing GRAFANA_SERVER
     with patch.dict(os.environ, {"GRAFANA_API_KEY": "api_key"}):
         with pytest.raises(ValueError) as e:
-            load_config_from_env(env_path=".env")
-        assert str(e.value) == "GRAFANA_SERVER is None or not defined in the .env file"
+            load_config_from_env(env_path="")
+        assert str(
+            e.value) == "GRAFANA_SERVER is None or not defined in the .env file"
 
     # Case 3: Test if function returns expected values when both variables are defined
-    with patch.dict(os.environ, {"GRAFANA_API_KEY": "api_key", "GRAFANA_SERVER": "server_url"}):
+    with patch.dict(
+        os.environ, {"GRAFANA_API_KEY": "api_key",
+                     "GRAFANA_SERVER": "server_url"}
+    ):
         result = load_config_from_env(env_path=".env")
-        assert result == ("server_url", "api_key")
\ No newline at end of file
+        assert result == ("server_url", "api_key")
-- 
GitLab