3636 "unsupported client/server combination" )
3737class TestCase (test_env .BaseTestCase ):
3838
39+ def __normalize_docs (self , docs ):
40+ """
41+ Remove the embedded OID added in Oracle Database 23c, if found, in
42+ order to ease comparison.
43+ """
44+ for doc in docs :
45+ if doc is not None and "_id" in doc :
46+ del doc ["_id" ]
47+
3948 def __test_skip (self , coll , num_to_skip , expected_content ):
4049 filter_spec = {'$orderby' : [{'path' : 'name' , 'order' : 'desc' }]}
4150 doc = coll .find ().filter (filter_spec ).skip (num_to_skip ).getOne ()
4251 content = doc .getContent () if doc is not None else None
52+ self .__normalize_docs ([content ])
4353 self .assertEqual (content , expected_content )
4454
4555 def test_3400_invalid_json (self ):
@@ -70,8 +80,9 @@ def test_3401_insert_documents(self):
7080 self .connection .commit ()
7181 self .assertEqual (coll .find ().count (), len (values_to_insert ))
7282 for key , value in zip (inserted_keys , values_to_insert ):
73- doc = coll .find ().key (key ).getOne ()
74- self .assertEqual (doc .getContent (), value )
83+ doc = coll .find ().key (key ).getOne ().getContent ()
84+ self .__normalize_docs ([doc ])
85+ self .assertEqual (doc , value )
7586 coll .drop ()
7687
7788 def test_3402_skip_documents (self ):
@@ -104,8 +115,9 @@ def test_3403_replace_document(self):
104115 new_content = {'name' : 'John' , 'address' : {'city' :'Melbourne' }}
105116 coll .find ().key (doc .key ).replaceOne (new_content )
106117 self .connection .commit ()
107- self .assertEqual (coll .find ().key (doc .key ).getOne ().getContent (),
108- new_content )
118+ doc = coll .find ().key (doc .key ).getOne ().getContent ()
119+ self .__normalize_docs ([doc ])
120+ self .assertEqual (doc , new_content )
109121 coll .drop ()
110122
111123 def test_3404_search_documents_with_content (self ):
@@ -260,15 +272,17 @@ def test_3410_document_version(self):
260272 inserted_doc = coll .insertOneAndGet (content )
261273 key = inserted_doc .key
262274 version = inserted_doc .version
263- doc = coll .find ().key (key ).version (version ).getOne ()
264- self .assertEqual (doc .getContent (), content )
275+ doc = coll .find ().key (key ).version (version ).getOne ().getContent ()
276+ self .__normalize_docs ([doc ])
277+ self .assertEqual (doc , content )
265278 new_content = {'name' : 'James' , 'address' : {'city' : 'Delhi' }}
266279 replacedDoc = coll .find ().key (key ).replaceOneAndGet (new_content )
267280 new_version = replacedDoc .version
268281 doc = coll .find ().key (key ).version (version ).getOne ()
269282 self .assertEqual (doc , None )
270- doc = coll .find ().key (key ).version (new_version ).getOne ()
271- self .assertEqual (doc .getContent (), new_content )
283+ doc = coll .find ().key (key ).version (new_version ).getOne ().getContent ()
284+ self .__normalize_docs ([doc ])
285+ self .assertEqual (doc , new_content )
272286 self .assertEqual (coll .find ().key (key ).version (version ).remove (), 0 )
273287 self .assertEqual (coll .find ().key (key ).version (new_version ).remove (), 1 )
274288 self .assertEqual (coll .find ().count (), 0 )
@@ -473,6 +487,8 @@ def test_3420_save_and_get(self):
473487 def test_3421_insert_many_and_get (self ):
474488 "3421 - test insert many and get"
475489 soda_db = self .get_soda_database (minclient = (18 , 5 ))
490+ for name in soda_db .getCollectionNames ():
491+ soda_db .openCollection (name ).drop ()
476492 coll = soda_db .createCollection ("TestInsertManyAndGet" )
477493 values_to_insert = [
478494 dict (name = "George" , age = 25 ),
@@ -485,8 +501,9 @@ def test_3421_insert_many_and_get(self):
485501 for key , expected_doc in zip (inserted_keys , values_to_insert ):
486502 if isinstance (expected_doc , dict ):
487503 expected_doc = soda_db .createDocument (expected_doc )
488- doc = coll .find ().key (key ).getOne ()
489- self .assertEqual (doc .getContent (), expected_doc .getContent ())
504+ doc = coll .find ().key (key ).getOne ().getContent ()
505+ self .__normalize_docs ([doc ])
506+ self .assertEqual (doc , expected_doc .getContent ())
490507 coll .drop ()
491508
492509 def test_3422_close_cursor (self ):
@@ -540,6 +557,7 @@ def test_3425_map_mode(self):
540557 coll = soda_db .createCollection ("TestSodaMapMode" , mapMode = mapMode )
541558 coll .insertMany (data )
542559 fetched_data = list (d .getContent () for d in coll .find ().getDocuments ())
560+ self .__normalize_docs (fetched_data )
543561 self .assertEqual (fetched_data , expected_data )
544562 self .assertRaisesRegex (oracledb .DatabaseError , "^ORA-40626" ,
545563 coll .drop )
@@ -615,6 +633,8 @@ def test_3429_getting_indexes(self):
615633 "3429 - test getting indexes on a collection"
616634 soda_db = self .get_soda_database ()
617635 coll = soda_db .createCollection ("TestSodaGetIndexes" )
636+ coll .drop ()
637+ coll = soda_db .createCollection ("TestSodaGetIndexes" )
618638 index_1 = {
619639 'name' : 'ix_3428-1' ,
620640 'fields' : [
0 commit comments