def setUp(self):

        self.maxDiff = None

        self.app = acmapi.create_app(SQLALCHEMY_DATABASE_URI='sqlite://')
        self.app.testing = True
        
        with self.app.test_request_context():
            DB.create_all()
            person = Person.create(
                name = None,
                username = '******',
                email = None,
                website = None,
                password = '******',
            )
            DB.session.add(person)
            DB.session.commit()

            officership = Officership.create(
                person = person,
                title = 'Vice Chair',        
                start_date = datetime.date.today(),
                end_date = None,
            )

            DB.session.add(person)
            DB.session.add(officership)
            DB.session.commit()
Example #2
0
    def test_create_officership_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="******",
            )

            officership = Officership.create(
                person=person,
                title="Vice Chair",
                start_date=datetime.date(2000, 1, 2),
                end_date=datetime.date(2000, 1, 3),
            )

            DB.session.add(officership)

            DB.session.commit()

            self.assertEqual(officership.id, 1)

            self.assertEqual(repr(officership), "<Officership(1)>")

            DB.session.delete(officership)

            DB.session.commit()
Example #3
0
    def test_create_officership_with_null_title(self):
        with self.app.test_request_context():

            DB.create_all()

            person = Person.create(
                name="John Doe",
                username="******",
                email="*****@*****.**",
                website="http://johnd.com",
                password="******",
            )

            officership = Officership.create(
                person=person, title=None, start_date=datetime.date(2000, 1, 2), end_date=datetime.date(2000, 1, 3)
            )

            DB.session.add(officership)

            try:
                DB.session.commit()
            except Exception:
                pass
            else:
                raise Exception("IntegrityError excepted but not thrown")
Example #4
0
    def test_create_officership_with_null_person(self):
        with self.app.test_request_context():

            DB.create_all()

            officership = Officership.create(
                person=None,
                title="Vice Chair",
                start_date=datetime.date(2000, 1, 2),
                end_date=datetime.date(2000, 1, 3),
            )

            DB.session.add(officership)

            try:
                DB.session.commit()
            except Exception:
                pass
            else:
                raise Exception("IntegrityError excepted but not thrown")
Example #5
0
from acmapi.models import Person, Officership
import datetime

app = create_app(SQLALCHEMY_DATABASE_URI='sqlite:///')

with app.test_request_context():
    DB.drop_all()
    DB.create_all()
    person = Person.create(
        name = None,
        username = '******',
        email = None,
        website = None,
        password = '******',
    )
    DB.session.add(person)
    DB.session.commit()

    officership = Officership.create(
        person = person,
        title = 'Root',        
        start_date = datetime.date.today(),
        end_date = None,
    )

    DB.session.add(person)
    DB.session.add(officership)
    DB.session.commit()

app.run()