@@ -129,30 +129,48 @@ async def test_slash_keys(self) -> None:
129129 """Test that slash keys work."""
130130 k = "/key"
131131 # set
132- await self .db .set (k ,"val1" )
133- self .assertEqual (await self .db .get (k ), "val1" )
132+ await self .db .set (k , "val1" )
133+ # TODO: Getting slash keys is currently not supported
134+ # See https://github.com/replit/replit-py/pull/218#discussion_r1588295348
135+ # self.assertEqual(await self.db.get(k), "val1")
136+ self .assertEqual (list (await self .db .list ("/" )), [k ])
134137 await self .db .delete (k )
138+ # TODO: Getting slash keys is currently not supported
139+ # KeyError is the same though, so it can stay.
135140 with self .assertRaises (KeyError ):
136141 await self .db .get (k )
137142 # set_raw
138- await self .db .set_raw (k ,"val1" )
139- self .assertEqual (await self .db .get_raw (k ), "val1" )
143+ await self .db .set_raw (k , "val1" )
144+ # TODO: Getting slash keys is currently not supported
145+ # self.assertEqual(await self.db.get_raw(k), "val1")
146+ self .assertEqual (list (await self .db .list ("/" )), [k ])
140147 await self .db .delete (k )
148+ # TODO: Getting slash keys is currently not supported.
149+ # KeyError is the same though, so it can stay.
141150 with self .assertRaises (KeyError ):
142151 await self .db .get (k )
143152 # set_bulk
144153 await self .db .set_bulk ({k : "val1" })
145- self .assertEqual (await self .db .get (k ), "val1" )
154+ # TODO: Getting slash keys is currently not supported
155+ # self.assertEqual(await self.db.get(k), "val1")
156+ self .assertEqual (list (await self .db .list ("/" )), [k ])
146157 await self .db .delete (k )
158+ # TODO: Getting slash keys is currently not supported
159+ # KeyError is the same though, so it can stay.
147160 with self .assertRaises (KeyError ):
148161 await self .db .get (k )
149162 # set_bulk_raw
150163 await self .db .set_bulk_raw ({k : "val1" })
151- self .assertEqual (await self .db .get_raw (k ), "val1" )
164+ # TODO: Getting slash keys is currently not supported
165+ # self.assertEqual(await self.db.get_raw(k), "val1")
166+ self .assertEqual (list (await self .db .list ("/" )), [k ])
152167 await self .db .delete (k )
168+ # TODO: Getting slash keys is currently not supported
169+ # KeyError is the same though, so it can stay.
153170 with self .assertRaises (KeyError ):
154171 await self .db .get (k )
155172
173+
156174class TestDatabase (unittest .TestCase ):
157175 """Tests for replit.database.Database."""
158176
@@ -291,26 +309,43 @@ def test_slash_keys(self) -> None:
291309 """Test that slash keys work."""
292310 k = "/key"
293311 # set
294- self .db .set (k ,"val1" )
295- self .assertEqual (self .db [k ], "val1" )
312+ self .db .set (k , "val1" )
313+ # TODO: Getting slash keys is currently not supported
314+ # See https://github.com/replit/replit-py/pull/218#discussion_r1588295348
315+ # self.assertEqual(self.db[k], "val1")
316+ self .assertEqual (list (self .db .keys ()), [k ])
296317 del self .db [k ]
318+ # TODO: Getting slash keys is currently not supported
319+ # KeyError is the same though, so it can stay.
297320 with self .assertRaises (KeyError ):
298321 self .db [k ]
299322 # set_raw
300- self .db .set_raw (k ,"val1" )
301- self .assertEqual (self .db .get_raw (k ), "val1" )
323+ self .db .set_raw (k , "val1" )
324+ # TODO: Getting slash keys is currently not supported
325+ # self.assertEqual(self.db.get_raw(k), "val1")
326+ self .assertEqual (list (self .db .keys ()), [k ])
302327 del self .db [k ]
328+ # TODO: Getting slash keys is currently not supported
329+ # KeyError is the same though, so it can stay.
303330 with self .assertRaises (KeyError ):
304331 self .db [k ]
305332 # set_bulk
306333 self .db .set_bulk ({k : "val1" })
307- self .assertEqual (self .db .get (k ), "val1" )
334+ # TODO: Getting slash keys is currently not supported
335+ # self.assertEqual(self.db.get(k), "val1")
336+ self .assertEqual (list (self .db .keys ()), [k ])
308337 del self .db [k ]
338+ # TODO: Getting slash keys is currently not supported
339+ # KeyError is the same though, so it can stay.
309340 with self .assertRaises (KeyError ):
310341 self .db [k ]
311342 # set_bulk_raw
312343 self .db .set_bulk_raw ({k : "val1" })
313- self .assertEqual (self .db .get_raw (k ), "val1" )
344+ # TODO: Getting slash keys is currently not supported
345+ # self.assertEqual(self.db.get_raw(k), "val1")
346+ self .assertEqual (list (self .db .keys ()), [k ])
314347 del self .db [k ]
348+ # TODO: Getting slash keys is currently not supported
349+ # KeyError is the same though, so it can stay.
315350 with self .assertRaises (KeyError ):
316351 self .db [k ]
0 commit comments