i am trying to mock sqlalchemy session.add such that when i insert session.add(order) and commit it , it should give me order.orderId back which i will use to extends the test case further .
session.add(order)
session.commit()
return order.orderId
i have mocked sessionMaker i.e mocker.patch.object(file_name, "create_pgdb_engine")
which return me mock but i am getting error like
Instance has a NULL identity key. If this is an auto-generated value, check that the database table allows generation of new primary key values, and that the mapped Column object is configured to expect these generated values. Ensure also that this flush() is not occurring at an inappropriate time, such as within a order() event.