From 035b2a6d5fab0d2d99ee3384e185e4f559488ee2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20Schr=C3=B6der?=
 <fschroeder@techfak.uni-bielefeld.de>
Date: Thu, 29 Feb 2024 10:00:01 +0100
Subject: [PATCH] Implement coverage measurement for tests

The pytest command in .gitlab-ci.yml has been updated to include code coverage measurements. The "coverage" Python package was added in setup.py under test requirements. Also, small updates were made in tests to reflect changes in the module imports and object comparisons.
---
 .gitlab-ci.yml                  |  2 +-
 setup.py                        |  1 +
 tests/test_cooking_equipment.py | 10 +++++++---
 tests/test_item.py              |  2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 20c922cf..8072058b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,7 +5,7 @@ pytest:
     - apt-get install -y python3-dev python3-pip graphviz graphviz-dev
     - pip install pytest
     - pip install .
-    - pytest --junitxml=report.xml
+    - coverage run -m pytest --junitxml=report.xml
   artifacts:
     when: always
     reports:
diff --git a/setup.py b/setup.py
index 658851b4..6d4c0062 100644
--- a/setup.py
+++ b/setup.py
@@ -32,6 +32,7 @@ requirements = [
 
 test_requirements = [
     "pytest>=3",
+    "coverage>=7.4.3",
 ]
 
 setup(
diff --git a/tests/test_cooking_equipment.py b/tests/test_cooking_equipment.py
index acb8af74..5bc9fa3b 100644
--- a/tests/test_cooking_equipment.py
+++ b/tests/test_cooking_equipment.py
@@ -1,6 +1,6 @@
 import pytest
 
-from overcooked_simulator.game_items import ItemInfo, CookingEquipment, Item, ItemType
+from cooperative_cuisine.game_items import ItemInfo, CookingEquipment, Item, ItemType
 
 
 def test_can_combine_single_other_item():
@@ -61,12 +61,16 @@ def test_progress():
     cooking_equipment = CookingEquipment(
         transitions={}, name="Pot", item_info=item_info
     )
-    cooking_equipment.active_transition = {"seconds": 5.0, "result": "TestResult"}
+    result = Item(name="TestResult", item_info=None)
+    cooking_equipment.active_transition = {
+        "seconds": 5.0,
+        "result": result,
+    }
     from datetime import datetime, timedelta
 
     cooking_equipment.progress(passed_time=timedelta(seconds=5.0), now=datetime.now())
 
-    assert cooking_equipment.content_list == ["TestResult"]
+    assert cooking_equipment.content_list == [result]
 
 
 def test_reset_content():
diff --git a/tests/test_item.py b/tests/test_item.py
index 97526461..9b3cdb64 100644
--- a/tests/test_item.py
+++ b/tests/test_item.py
@@ -1,6 +1,6 @@
 import pytest
 
-from overcooked_simulator.game_items import ItemInfo, Item, ItemType
+from cooperative_cuisine.game_items import ItemInfo, Item, ItemType
 
 
 @pytest.fixture
-- 
GitLab