1+ import datetime
12import time
23
4+ from ravendb import MetadataAsDictionary , constants
35from ravendb .tests .test_base import TestBase
46
57
@@ -40,7 +42,7 @@ def test_simple_bulk_insert_should_work(self):
4042 self .assertEqual ("Mega John" , doc3 .name )
4143 self .assertEqual ("Mega Jane" , doc4 .name )
4244
43- def test_should_not_acept_ids_ending_with_pipe_line (self ):
45+ def test_should_not_accept_ids_ending_with_pipe_line (self ):
4446 with self .store .bulk_insert () as bulk_insert :
4547 self .assertRaisesWithMessage (
4648 bulk_insert .store ,
@@ -49,3 +51,17 @@ def test_should_not_acept_ids_ending_with_pipe_line(self):
4951 FooBar (),
5052 "foobars|" ,
5153 )
54+
55+ def test_can_modify_metadata_with_bulk_insert (self ):
56+ expiration_date = (datetime .datetime .utcnow () + datetime .timedelta (days = 365 )).isoformat () + "0Z" # add one year
57+
58+ with self .store .bulk_insert () as bulk_insert :
59+ foobar = FooBar ("Jon Snow" )
60+ metadata = MetadataAsDictionary ()
61+ metadata [constants .Documents .Metadata .EXPIRES ] = expiration_date
62+ bulk_insert .store_by_entity (foobar , metadata )
63+
64+ with self .store .open_session () as session :
65+ entity = session .load ("FooBars/1-A" , FooBar )
66+ metadata_expiration_date = session .advanced .get_metadata_for (entity )[constants .Documents .Metadata .EXPIRES ]
67+ self .assertEqual (expiration_date , metadata_expiration_date )
0 commit comments