Skip to content

Commit 2ba0880

Browse files
committed
fix: session tests
1 parent 254bb5c commit 2ba0880

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

backend/tests/test_session.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from flask import Flask
3-
from tenantfirstaid.session import TenantSession, InitSessionView
4-
from typing import Dict, Any
3+
from tenantfirstaid.session import TenantSession, InitSessionView, TenantSessionData
4+
from typing import Dict
55

66

77
@pytest.fixture
@@ -104,11 +104,11 @@ def test_session_get_unknown_session_id(mocker, mock_environ):
104104

105105

106106
def test_session_set_and_get(mocker, mock_environ, mock_valkey):
107-
test_data_obj: Dict[str, Any] = {
108-
"city": "Test City",
109-
"state": "Test State",
110-
"messages": ["this is message 1", "this is message 2"],
111-
}
107+
test_data_obj = TenantSessionData(
108+
city="Test City",
109+
state="Test State",
110+
messages=[],
111+
)
112112

113113
tenant_session = TenantSession()
114114
app = Flask(__name__)
@@ -126,16 +126,16 @@ def test_session_set_and_get(mocker, mock_environ, mock_valkey):
126126
assert session_id is not None # Ensure session_id is set
127127
assert isinstance(session_id, str) # Ensure session_id is a string
128128

129-
tenant_session.set(session_id, test_data_obj)
129+
tenant_session.set(test_data_obj)
130130
assert tenant_session.get() == test_data_obj
131131

132132

133133
def test_session_set_some_and_get_none(mocker, mock_environ, mock_valkey):
134-
test_data_obj: Dict[str, Any] = {
135-
"city": "Test City",
136-
"state": "Test State",
137-
"messages": ["this is message 1", "this is message 2"],
138-
}
134+
test_data_obj = TenantSessionData(
135+
city="Test City",
136+
state="Test State",
137+
messages=[],
138+
)
139139

140140
tenant_session = TenantSession()
141141
app = Flask(__name__)
@@ -156,9 +156,9 @@ def test_session_set_some_and_get_none(mocker, mock_environ, mock_valkey):
156156
assert session_id is not None # Ensure session_id is set
157157
assert isinstance(session_id, str) # Ensure session_id is a string
158158

159-
tenant_session.set(session_id, test_data_obj)
159+
tenant_session.set(test_data_obj)
160160
assert tenant_session.get() == {
161-
"city": "",
162-
"state": "",
161+
"city": "null",
162+
"state": "or",
163163
"messages": [],
164164
}

0 commit comments

Comments
 (0)