def test_create_membership_with_invalid_end_date(self): with self.app.test_request_context(): DB.create_all() person = Person.create( name="John Doe", username="******", email="*****@*****.**", website="http://johnd.com", password="******", ) membership = Membership.create( person=person, start_date=datetime.date(2000, 1, 1), end_date=datetime.date(2000, 1, 1) ) DB.session.add(membership) try: DB.session.commit() except Exception: pass else: raise Exception("IntegrityError excepted but not thrown")
def test_create_membership_with_valid_end_date(self): with self.app.test_request_context(): DB.create_all() person = Person.create( name="John Doe", username="******", email="*****@*****.**", website="http://johnd.com", password="******", ) membership = Membership.create( person=person, start_date=datetime.date(2000, 1, 1), end_date=datetime.date(2000, 1, 2) ) DB.session.add(membership) DB.session.commit() self.assertEqual(membership.id, 1) self.assertEqual(repr(membership), "<Membership(1)>") DB.session.delete(membership) DB.session.commit()
def test_create_membership_with_null_person(self): with self.app.test_request_context(): DB.create_all() membership = Membership.create( person=None, start_date=datetime.date(2000, 1, 1), end_date=datetime.date(2000, 1, 2) ) DB.session.add(membership) try: DB.session.commit() except Exception: pass else: raise Exception("IntegrityError excepted but not thrown")