def test_copy_unsaved(historian: mincepy.Historian): car = Car('porsche', 'silver') car_copy = mincepy.copy(car) assert car_copy is not car assert car == car_copy # The cars should not be saved assert not historian.is_known(car) assert not historian.is_known(car_copy)
def test_meta_stick_copy(historian: mincepy.Historian): """Test that sticky meta is applied to objects that are copied. Issue #13: https://github.com/muhrin/mincepy/issues/13""" car = Car() historian.meta.sticky.update({'owner': 'martin'}) car.save() car_copy = mincepy.copy(car) car_copy.save() assert historian.meta.get(car) == {'owner': 'martin'} assert historian.meta.get(car_copy) == {'owner': 'martin'}
def test_copy(historian: mincepy.Historian): car = Car('zonda') historian.save(car) car_copy = mincepy.copy(car) assert car == car_copy assert car is not car_copy car_copy.save() record = historian.get_current_record(car) copy_record = historian.get_current_record(car_copy) assert record is not copy_record assert copy_record.get_copied_from() == record.snapshot_id