Skip to content

Commit

Permalink
fix tests after migrating defns to core & also changing from Enum to …
Browse files Browse the repository at this point in the history
…StrEnum for status classes
  • Loading branch information
galenseilis committed Dec 1, 2024
1 parent 483fa36 commit 5270192
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 39 deletions.
6 changes: 3 additions & 3 deletions src/desimpy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from __future__ import annotations

import heapq # pragma: nocover
from enum import Enum, auto
from enum import StrEnum, auto
from typing import TYPE_CHECKING # pragma: nocover

if TYPE_CHECKING:
Expand All @@ -37,7 +37,7 @@
####################


class EventStatus(Enum):
class EventStatus(StrEnum):
"""The status of an event."""

INACTIVE = auto()
Expand Down Expand Up @@ -135,7 +135,7 @@ def __lt__(self, other: Self):
##############################


class EventSchedulerStatus(Enum):
class EventSchedulerStatus(StrEnum):
"""The status of an event scheduler."""

INACTIVE = auto()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_event_class/test_method__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from desimpy import Event, EventStatus
from desimpy.core import Event, EventStatus


def test_event_initialization_default():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_event_class/test_method_activate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import Event, EventStatus
from desimpy.core import Event, EventStatus


def test_already_active():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_event_class/test_method_deactivate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import Event, EventStatus
from desimpy.core import Event, EventStatus


def test_deactivate_new():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus


def test_activate_all_events_no_events():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus

# Sample condition functions for testing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus


def test_activate_next_event_by_condition_single_event_true():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus


def test_deactivate_all_events_no_events():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus

# Sample condition functions for testing

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus

# Test Suite for deactivate_next_event

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import Event, EventScheduler, EventStatus
from desimpy.core import Event, EventScheduler, EventStatus

# Test Suite for deactivate_next_event_by_condition

Expand Down
23 changes: 6 additions & 17 deletions tests/test_eventschedulerstatus_class/test_eventschedulerstatus.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
from desimpy import EventSchedulerStatus


def test_event_scheduler_status_members():
"""Ensure the EventSchedulerStatus enum contains the correct members."""
assert hasattr(
EventSchedulerStatus, "INACTIVE"
), "INACTIVE should be a member of EventSchedulerStatus."
assert hasattr(
EventSchedulerStatus, "ACTIVE"
), "ACTIVE should be a member of EventSchedulerStatus."

from desimpy.core import EventSchedulerStatus

def test_event_scheduler_status_auto_values():
"""Verify the auto-assigned values for the EventSchedulerStatus enum."""
assert (
EventSchedulerStatus.INACTIVE.value == 1
), "INACTIVE should have a value of 1."
assert EventSchedulerStatus.ACTIVE.value == 2, "ACTIVE should have a value of 2."
EventSchedulerStatus.INACTIVE.value == "inactive"
), "INACTIVE should have a value of inactive."
assert EventSchedulerStatus.ACTIVE.value == "active", "ACTIVE should have a value of active."


def test_event_scheduler_status_distinction():
Expand Down Expand Up @@ -48,8 +37,8 @@ def test_event_scheduler_status_names():
def test_event_scheduler_status_str_representation():
"""Ensure the string representation of EventSchedulerStatus members is correct."""
assert (
str(EventSchedulerStatus.INACTIVE) == "EventSchedulerStatus.INACTIVE"
str(EventSchedulerStatus.INACTIVE) == "inactive"
), "String representation of INACTIVE is incorrect."
assert (
str(EventSchedulerStatus.ACTIVE) == "EventSchedulerStatus.ACTIVE"
str(EventSchedulerStatus.ACTIVE) == "active"
), "String representation of ACTIVE is incorrect."
13 changes: 7 additions & 6 deletions tests/test_eventstatus_class/test_eventstatus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from desimpy import EventStatus
from desimpy.core import EventStatus


def test_event_status_members():
Expand All @@ -11,8 +11,8 @@ def test_event_status_members():

def test_event_status_values():
"""Test the auto-assigned values of EventStatus members."""
assert EventStatus.INACTIVE.value == 1, "INACTIVE should have a value of 1."
assert EventStatus.ACTIVE.value == 2, "ACTIVE should have a value of 2."
assert EventStatus.INACTIVE.value == "inactive", "INACTIVE should have a value of 1."
assert EventStatus.ACTIVE.value == "active", "ACTIVE should have a value of 2."


def test_event_status_comparisons():
Expand All @@ -21,7 +21,7 @@ def test_event_status_comparisons():
EventStatus.INACTIVE != EventStatus.ACTIVE
), "INACTIVE and ACTIVE should not be equal."
assert (
EventStatus.INACTIVE.value < EventStatus.ACTIVE.value
EventStatus.INACTIVE.value > EventStatus.ACTIVE.value
), "INACTIVE should have a smaller value than ACTIVE."


Expand All @@ -36,9 +36,10 @@ def test_event_status_iteration():

def test_event_status_string_representation():
"""Test the string representation of EventStatus members."""
print(EventStatus.ACTIVE)
assert (
str(EventStatus.INACTIVE) == "EventStatus.INACTIVE"
str(EventStatus.INACTIVE) == "inactive"
), "String representation of INACTIVE is incorrect."
assert (
str(EventStatus.ACTIVE) == "EventStatus.ACTIVE"
str(EventStatus.ACTIVE) == "active"
), "String representation of ACTIVE is incorrect."

0 comments on commit 5270192

Please sign in to comment.