Exemplo n.º 1
0
    def test_mde_sequence(self):
        TmsApp()

        self.meet = Meet.init_meet({
            'name': 'TestMeet',
            'date': "August 5, 2018",
            'division_order': ['7F', '7M'],
            'event_order': ['PV', '200M', '4x400M']
        })
        q_mdes = MeetDivisionEvent.query.filter_by(meet=self.meet)
        mdes = q_mdes.order_by(MeetDivisionEvent.seq_num)

        self.assertEqual(mdes[0].event.code, "PV")
        self.assertEqual(mdes[0].division.code, "7F")
        self.assertEqual(mdes[1].event.code, "PV")
        self.assertEqual(mdes[1].division.code, "7M")

        self.assertEqual(mdes[2].event.code, "200M")
        self.assertEqual(mdes[2].division.code, "7F")
        self.assertEqual(mdes[3].event.code, "200M")
        self.assertEqual(mdes[3].division.code, "7M")

        self.assertEqual(mdes[4].event.code, "4x400M")
        self.assertEqual(mdes[4].division.code, "7F")
        self.assertEqual(mdes[5].event.code, "4x400M")
        self.assertEqual(mdes[5].division.code, "7M")
Exemplo n.º 2
0
    def setUp(self):
        setup_test_app_db()
        db.create_all()
        self.client = app.test_client()

        TmsApp()
        self.meet = Meet.init_meet(EXAMPLE_MEETS[0])
Exemplo n.º 3
0
    def test_TmsApp(self):
        # everything should be empty before
        self.assertEqual(Meet.query.count(), 0)
        self.assertEqual(Athlete.query.count(), 0)
        self.assertEqual(Entry.query.count(), 0)
        self.assertEqual(MeetDivisionEvent.query.count(), 0)
        self.assertEqual(School.query.count(), 0)
        self.assertEqual(EventDefinition.query.count(), 0)
        self.assertEqual(EventOrdering.query.count(), 0)
        self.assertEqual(Division.query.count(), 0)
        self.assertEqual(DivOrdering.query.count(), 0)
        self.assertEqual(User.query.count(), 0)

        TmsApp()

        # After TmsApp, User, School, EventDef and Division
        # tables should have data, but no other tables.
        self.assertEqual(User.query.count(), 1)
        self.assertEqual(School.query.count(), 1)
        self.assertEqual(EventDefinition.query.count(), len(EVENT_DEFS))
        self.assertEqual(Division.query.count(),
                         (len(GENDERS) * len(MIDDLE_SCHOOL_GRADES)) +
                         len(GENDERS))

        self.assertEqual(Meet.query.count(), 0)
        self.assertEqual(Athlete.query.count(), 0)
        self.assertEqual(Entry.query.count(), 0)
        self.assertEqual(MeetDivisionEvent.query.count(), 0)
        self.assertEqual(EventOrdering.query.count(), 0)
        self.assertEqual(DivOrdering.query.count(), 0)
Exemplo n.º 4
0
    def setUp(self):
        setup_test_app_db()
        db.create_all()
        self.client = app.test_client()

        TmsApp()
        self.meet = Meet.init_meet(EXAMPLE_MEETS[0])

        self.school = School(name="Hackbright", code="HBRT")
        db.session.add(self.school)
        db.session.commit()
Exemplo n.º 5
0
 def test_event_to_mde_relationship(self):
     TmsApp()
     self.meet = Meet.init_meet({
         'name':
         'TestMeet',
         'date':
         "August 5, 2018",
         'division_order': ['6F', '7F', '8F', '6M', '7M', '8M'],
         'event_order': ['PV', '200M', '4x400M', 'HJ']
     })
     e = EventDefinition.query.filter_by(code="1600M").all()
Exemplo n.º 6
0
 def test_count_EventOrdering(self):
     TmsApp()
     self.meet = Meet.init_meet({
         'name': 'TestMeet',
         'date': "August 5, 2018",
         'division_order': ['7F', '7M'],
         'event_order': ['PV', '200M', '4x400M']
     })
     self.assertEqual(
         EventOrdering.query.filter_by(meet=self.meet).count(), 3)
     self.assertEqual(EventDefinition.query.count(), len(EVENT_DEFS))
Exemplo n.º 7
0
    def test_count_mdes(self):
        TmsApp()

        self.meet = Meet.init_meet({
            'name': 'TestMeet',
            'date': "August 5, 2018",
            'division_order': ['7F', '7M'],
            'event_order': ['PV', '200M', '4x400M']
        })
        num_mdes_overall = MeetDivisionEvent.query.count()
        num_mdes_this_meet = MeetDivisionEvent.query.filter_by(
            meet=self.meet).count()
        self.assertEqual(num_mdes_overall, num_mdes_this_meet)
        self.assertEqual(num_mdes_this_meet, 6)
Exemplo n.º 8
0
    def test_host_school(self):
        TmsApp()
        lghs = School(name="Los Gatos High School", code="LOGA")
        db.session.add(lghs)
        db.session.commit()

        meet1 = Meet.init_meet({"name": "Meet #1", "date": "October 28, 2018"})
        meet1.host_school = lghs
        meet2 = Meet.init_meet({"name": "Meet #2", "date": "November 5, 2018"})
        meet2.host_school = lghs

        self.assertIn(meet1, lghs.meets_hosted)
        self.assertIn(meet2, lghs.meets_hosted)
        self.assertEqual(len(lghs.meets_hosted), 2)

        self.assertEqual(lghs.meets_hosted[0].name, "Meet #1")
        self.assertEqual(lghs.meets_hosted[1].name, "Meet #2")
Exemplo n.º 9
0
    def setUp(self):
        info("testVerifyEmptyDatabase - setup")
        setup_test_app_db()
        db.create_all()
        self.client = app.test_client()
        self.assertEqual(0, Meet.query.count())
        self.assertEqual(0, Athlete.query.count())
        self.assertEqual(0, Entry.query.count())
        self.assertEqual(0, MeetDivisionEvent.query.count())
        self.assertEqual(0, School.query.count())
        self.assertEqual(0, EventDefinition.query.count())
        self.assertEqual(0, EventOrdering.query.count())
        self.assertEqual(0, Division.query.count())
        self.assertEqual(0, DivOrdering.query.count())
        self.assertEqual(0, User.query.count())

        TmsApp()
        self.meet1 = Meet.init_meet(EXAMPLE_MEETS[0])
Exemplo n.º 10
0
    def test_init_meet_no_event_div_orders(self):
        # if we don't provide dictionary with 'event_order' or 'division_order'
        # keys, then we assume the meet includes all possible EventDefinitions
        # and Divisions already defined.
        TmsApp()
        meet = Meet.init_meet({'name': 'TestMeet', 'date': "August 5, 2018"})

        num_mdes = MeetDivisionEvent.query.count()
        self.assertEqual(
            num_mdes,
            len(EVENT_DEFS) * len(GENDERS) *
            # There are also all-M and all-F divisions.  We didn't provide
            # a division_list to init_meet, so we're using ALL 8 divisions
            (len(MIDDLE_SCHOOL_GRADES) + 1))
        self.assertEqual(
            DivOrdering.query.filter_by(meet=meet).count(),
            len(GENDERS) * (len(MIDDLE_SCHOOL_GRADES) + 1))
        self.assertEqual(
            EventOrdering.query.filter_by(meet=meet).count(), len(EVENT_DEFS))
Exemplo n.º 11
0
    def test_mde_meet_division_event_relationships(self):
        TmsApp()
        self.meet = Meet.init_meet({
            'name':
            'TestMeet',
            'date':
            "August 5, 2018",
            'division_order': ['6F', '7F', '8F', '6M', '7M', '8M'],
            'event_order': ['PV', '200M', '4x400M', 'HJ']
        })

        g7 = Division.query.filter_by(grade="7", gender="F").one()
        hj = EventDefinition.query.filter_by(code="HJ").one()

        q = MeetDivisionEvent.query.filter_by(meet=self.meet)
        q = q.filter_by(division=g7, event=hj)
        meet_g7_hj = q.one()

        self.assertEqual(meet_g7_hj.division.code, "7F")
        self.assertEqual(meet_g7_hj.event.name, "High Jump")
        self.assertEqual(meet_g7_hj.meet.name, "TestMeet")
Exemplo n.º 12
0
    def setUp(self):
        setup_test_app_db()
        db.create_all()
        self.client = app.test_client()

        TmsApp()

        self.meet = Meet.init_meet({
            'name': 'TestEntryMarks Meet',
            'date': "August 5, 2018",
            'division_order': ['7F'],
            'event_order': ['1600M', 'LJ']
        })

        athlete = Athlete("Sue", "K", "Raisty", "F", "7")
        db.session.add(athlete)
        db.session.commit()
        self.athlete = athlete

        self.mde_1600m = MeetDivisionEvent.query.filter_by(
            meet=self.meet, event_code="1600M").one()
        self.mde_longjump = MeetDivisionEvent.query.filter_by(
            meet=self.meet, event_code="LJ").one()
Exemplo n.º 13
0
from parse_hytek import parse_hytek_file

from test_utils import EXAMPLE_MEETS
from util import info

NUM_MEETS = len(EXAMPLE_MEETS)
# NUM_MEETS = 3

if __name__ == "__main__":
    # reset database
    app = Flask(__name__)
    connect_to_db(app, "tms-dev", debug=False)
    info("Connected to database")
    reset_database()
    db.create_all()
    # create divs & events that are standard across all our meegs
    TmsApp()

    for i in range(NUM_MEETS):
        meet = Meet.init_meet(EXAMPLE_MEETS[i])

        parse_hytek_file("seed_data/{}".format(EXAMPLE_MEETS[i]['filename']),
                         meet)

    # Fix Unattached meets. Assign to Carmel HS.
    carmel = School.get.filter_by(code="CARM")
    unattached_meets = Meets.query.filter_by(host_school_id=1)
    for m in unattached_meets:
        m.host_school = carmel
    db.session.commit()
Exemplo n.º 14
0
 def setUp(self):
     setup_test_app_db()
     db.create_all()
     self.client = app.test_client()
     TmsApp()