def test_create_customer_job(self, book_basic, Person): EUR = book_basic.commodities(namespace="CURRENCY") # create detached person c = Person(name="John Föo", currency=EUR) book_basic.add(c) if Person != Employee: j = Job(name="my job", owner=c) book_basic.validate() book_basic.flush() if Person != Employee: print(c.jobs)
def test_create_person_id_nobook(self, book_basic, Person): EUR = book_basic.commodities(namespace="CURRENCY") # create person detached from book with a specific id cust_id = "éyO903" c = Person(name="John Föo", currency=EUR, id=cust_id) # id should have already been set assert c.id == cust_id # flushing should not change the id (as the person is not yet attached to book) book_basic.flush() assert c.id == cust_id # adding the person to the book and flushing should not change the id book_basic.add(c) assert c.id == cust_id book_basic.flush() assert c.id == cust_id
def test_create_person_noid_nobook(self, book_basic, Person): EUR = book_basic.commodities(namespace="CURRENCY") # create detached person c = Person(name="John Föo", currency=EUR) # id should not be set assert c.id is None # flushing should not set the id as person not added to book book_basic.flush() assert c.id is None # adding the person to the book does not per se set the id book_basic.add(c) assert c.id is None # but validation sets the id if still to None book_basic.validate() assert c.id == "000001"