33import pytest
44
55from models .cache_entry import CacheEntry
6- from cache .noop_cache import NoopCache
76from utils import suid
7+ from cache .noop_cache import NoopCache
88
99USER_ID = suid .get_suid ()
1010CONVERSATION_ID = suid .get_suid ()
2828
2929
3030@pytest .fixture (name = "cache_fixture" )
31- def cache ():
31+ def cache () -> NoopCache :
3232 """Fixture with constucted and initialized in memory cache object."""
3333 c = NoopCache ()
3434 c .initialize_cache ()
3535 return c
3636
3737
38- def test_connect (cache_fixture ) :
38+ def test_connect (cache_fixture : NoopCache ) -> None :
3939 """Test the behavior of connect method."""
4040 cache_fixture .connect ()
4141
4242
43- def test_insert_or_append (cache_fixture ) :
43+ def test_insert_or_append (cache_fixture : NoopCache ) -> None :
4444 """Test the behavior of insert_or_append method."""
4545 cache_fixture .insert_or_append (
4646 USER_ID ,
@@ -49,15 +49,15 @@ def test_insert_or_append(cache_fixture):
4949 )
5050
5151
52- def test_insert_or_append_skip_user_id_check (cache_fixture ) :
52+ def test_insert_or_append_skip_user_id_check (cache_fixture : NoopCache ) -> None :
5353 """Test the behavior of insert_or_append method."""
5454 skip_user_id_check = True
5555 cache_fixture .insert_or_append (
5656 USER_PROVIDED_USER_ID , CONVERSATION_ID , cache_entry_1 , skip_user_id_check
5757 )
5858
5959
60- def test_insert_or_append_existing_key (cache_fixture ) :
60+ def test_insert_or_append_existing_key (cache_fixture : NoopCache ) -> None :
6161 """Test the behavior of insert_or_append method for existing item."""
6262 cache_fixture .insert_or_append (
6363 USER_ID ,
@@ -71,15 +71,15 @@ def test_insert_or_append_existing_key(cache_fixture):
7171 )
7272
7373
74- def test_get_nonexistent_user (cache_fixture ) :
74+ def test_get_nonexistent_user (cache_fixture : NoopCache ) -> None :
7575 """Test how non-existent items are handled by the cache."""
7676 # this UUID is different from DEFAULT_USER_UID
7777 assert (
7878 cache_fixture .get ("ffffffff-ffff-ffff-ffff-ffffffffffff" , CONVERSATION_ID ) == []
7979 )
8080
8181
82- def test_delete_existing_conversation (cache_fixture ) :
82+ def test_delete_existing_conversation (cache_fixture : NoopCache ) -> None :
8383 """Test deleting an existing conversation."""
8484 cache_fixture .insert_or_append (USER_ID , CONVERSATION_ID , cache_entry_1 )
8585
@@ -88,19 +88,19 @@ def test_delete_existing_conversation(cache_fixture):
8888 assert result is True
8989
9090
91- def test_delete_nonexistent_conversation (cache_fixture ) :
91+ def test_delete_nonexistent_conversation (cache_fixture : NoopCache ) -> None :
9292 """Test deleting a conversation that doesn't exist."""
9393 result = cache_fixture .delete (USER_ID , CONVERSATION_ID )
9494 assert result is True
9595
9696
97- def test_delete_improper_conversation_id (cache_fixture ) :
97+ def test_delete_improper_conversation_id (cache_fixture : NoopCache ) -> None :
9898 """Test delete with invalid conversation ID."""
9999 with pytest .raises (ValueError , match = "Invalid conversation ID" ):
100100 cache_fixture .delete (USER_ID , "invalid-id" )
101101
102102
103- def test_delete_skip_user_id_check (cache_fixture ) :
103+ def test_delete_skip_user_id_check (cache_fixture : NoopCache ) -> None :
104104 """Test deleting an existing conversation."""
105105 skip_user_id_check = True
106106 cache_fixture .insert_or_append (
@@ -114,7 +114,7 @@ def test_delete_skip_user_id_check(cache_fixture):
114114 assert result is True
115115
116116
117- def test_list_conversations (cache_fixture ) :
117+ def test_list_conversations (cache_fixture : NoopCache ) -> None :
118118 """Test listing conversations for a user."""
119119 # Create multiple conversations
120120 conversation_id_1 = suid .get_suid ()
@@ -128,7 +128,7 @@ def test_list_conversations(cache_fixture):
128128 assert len (conversations ) == 0
129129
130130
131- def test_list_conversations_skip_user_id_check (cache_fixture ) :
131+ def test_list_conversations_skip_user_id_check (cache_fixture : NoopCache ) -> None :
132132 """Test listing conversations for a user."""
133133 # Create multiple conversations
134134 conversation_id_1 = suid .get_suid ()
@@ -147,13 +147,13 @@ def test_list_conversations_skip_user_id_check(cache_fixture):
147147 assert len (conversations ) == 0
148148
149149
150- def test_list_no_conversations (cache_fixture ) :
150+ def test_list_no_conversations (cache_fixture : NoopCache ) -> None :
151151 """Test listing conversations for a user with no conversations."""
152152 conversations = cache_fixture .list (USER_ID )
153153 assert len (conversations ) == 0
154154
155155
156- def test_ready (cache_fixture ) :
156+ def test_ready (cache_fixture : NoopCache ) -> None :
157157 """Test if in memory cache always report ready."""
158158 assert cache_fixture .ready ()
159159
@@ -172,27 +172,27 @@ def test_ready(cache_fixture):
172172
173173
174174@pytest .mark .parametrize ("uuid" , improper_user_uuids )
175- def test_list_improper_user_id (cache_fixture , uuid ) :
175+ def test_list_improper_user_id (cache_fixture : NoopCache , uuid : str | None ) -> None :
176176 """Test list with invalid user ID."""
177177 with pytest .raises (ValueError , match = f"Invalid user ID { uuid } " ):
178178 cache_fixture .list (uuid )
179179
180180
181181@pytest .mark .parametrize ("uuid" , improper_user_uuids )
182- def test_delete_improper_user_id (cache_fixture , uuid ) :
182+ def test_delete_improper_user_id (cache_fixture : NoopCache , uuid : str | None ) -> None :
183183 """Test delete with invalid user ID."""
184184 with pytest .raises (ValueError , match = f"Invalid user ID { uuid } " ):
185185 cache_fixture .delete (uuid , CONVERSATION_ID )
186186
187187
188188@pytest .mark .parametrize ("uuid" , improper_user_uuids )
189- def test_get_improper_user_id (cache_fixture , uuid ) :
189+ def test_get_improper_user_id (cache_fixture : NoopCache , uuid : str | None ) -> None :
190190 """Test how improper user ID is handled."""
191191 with pytest .raises (ValueError , match = f"Invalid user ID { uuid } " ):
192192 cache_fixture .get (uuid , CONVERSATION_ID )
193193
194194
195- def test_get_improper_conversation_id (cache_fixture ) :
195+ def test_get_improper_conversation_id (cache_fixture : NoopCache ) -> None :
196196 """Test how improper conversation ID is handled."""
197197 with pytest .raises (ValueError , match = "Invalid conversation ID" ):
198198 cache_fixture .get (USER_ID , "this-is-not-valid-uuid" )
0 commit comments