Added Application HolidayViewer
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import pytest
|
||||
|
||||
from components.BaseComponent import BaseComponent
|
||||
from core.instance_manager import InstanceManager, SESSION_ID_KEY, NOT_LOGGED # Adjust import path as needed
|
||||
from constants import NO_SESSION, SESSION_USER_ID_KEY, NOT_LOGGED
|
||||
from core.instance_manager import InstanceManager
|
||||
|
||||
|
||||
class MockBaseComponent(BaseComponent):
|
||||
@@ -52,7 +53,7 @@ def session():
|
||||
"""
|
||||
Fixture to provide a default mocked session dictionary with a fixed user_id.
|
||||
"""
|
||||
return {SESSION_ID_KEY: "test_user"}
|
||||
return {SESSION_USER_ID_KEY: "test_user"}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -140,7 +141,7 @@ def test_register_registers_instance(session, base_component_instance):
|
||||
"""
|
||||
InstanceManager.register(session, base_component_instance)
|
||||
|
||||
key = (session[SESSION_ID_KEY], base_component_instance._id)
|
||||
key = (session[SESSION_USER_ID_KEY], base_component_instance._id)
|
||||
assert key in InstanceManager._instances
|
||||
assert InstanceManager._instances[key] == base_component_instance
|
||||
|
||||
@@ -167,7 +168,7 @@ def test_register_fetches_id_from_instance_attribute(session):
|
||||
instance = MockInstanceWithId()
|
||||
InstanceManager.register(session, instance)
|
||||
|
||||
key = (session[SESSION_ID_KEY], instance._id) # `_id` value taken from the instance
|
||||
key = (session[SESSION_USER_ID_KEY], instance._id) # `_id` value taken from the instance
|
||||
assert key in InstanceManager._instances
|
||||
assert InstanceManager._instances[key] == instance
|
||||
|
||||
@@ -181,8 +182,8 @@ def test_register_many_without_session():
|
||||
|
||||
InstanceManager.register_many(instance1, instance2)
|
||||
|
||||
key1 = (NOT_LOGGED, "id1")
|
||||
key2 = (NOT_LOGGED, "id2")
|
||||
key1 = (NO_SESSION, "id1")
|
||||
key2 = (NO_SESSION, "id2")
|
||||
assert key1 in InstanceManager._instances
|
||||
assert InstanceManager._instances[key1] == instance1
|
||||
assert key2 in InstanceManager._instances
|
||||
@@ -197,7 +198,7 @@ def test_remove_registered_instance(session, instance_id):
|
||||
InstanceManager.register(session, instance)
|
||||
|
||||
InstanceManager.remove(session, instance_id)
|
||||
key = (session[SESSION_ID_KEY], instance_id)
|
||||
key = (session[SESSION_USER_ID_KEY], instance_id)
|
||||
assert key not in InstanceManager._instances
|
||||
|
||||
|
||||
@@ -210,7 +211,7 @@ def test_remove_with_dispose_method(session, instance_id):
|
||||
InstanceManager.remove(session, instance_id)
|
||||
|
||||
assert hasattr(instance, "disposed") and instance.disposed
|
||||
key = (session[SESSION_ID_KEY], instance_id)
|
||||
key = (session[SESSION_USER_ID_KEY], instance_id)
|
||||
assert key not in InstanceManager._instances
|
||||
|
||||
|
||||
@@ -230,7 +231,7 @@ def test_get_session_id_returns_logged_in_user_id(session):
|
||||
Test that _get_session_id extracts the session ID correctly.
|
||||
"""
|
||||
session_id = InstanceManager.get_session_id(session)
|
||||
assert session_id == session[SESSION_ID_KEY]
|
||||
assert session_id == session[SESSION_USER_ID_KEY]
|
||||
|
||||
|
||||
def test_get_session_id_returns_default_logged_out_value():
|
||||
@@ -238,4 +239,7 @@ def test_get_session_id_returns_default_logged_out_value():
|
||||
Test that _get_session_id returns NOT_LOGGED when session is None.
|
||||
"""
|
||||
session_id = InstanceManager.get_session_id(None)
|
||||
assert session_id == NO_SESSION
|
||||
|
||||
session_id = InstanceManager.get_session_id({})
|
||||
assert session_id == NOT_LOGGED
|
||||
|
||||
Reference in New Issue
Block a user