def test_add_two_donors(): global database try: with database.transaction(): new_donor = Donor.create( name = 'Bob') new_donor.save() new_donor2 = Donor.create( name = 'Dave') new_donor2.save() logger.info('Reading and print donor') for donor in Donor: logger.info(f'{donor.name}') except Exception as e: logger.info(f'Error creating donor') logger.info(e) # with database.transaction(): count = Donor.select().count() print("count is", count) assert count == 2
def test_add_donation(): try: with database.transaction(): new_donor = Donor.create( name = 'Bob') new_donor.save() with database.transaction(): new_donation = Donation.create(donor_id=new_donor.name, amount=123.45) new_donation.save() except Exception as e: logger.info(f'Error creating donation') logger.info(e)