def test_create_multiple_meets(self):
     meet1 = Meet(name="WVAL League Practice Meet #1",
                  date="April 15, 2019")
     meet2 = Meet(name="WVAL League Practice Meet #2",
                  date="April 25, 2019")
     meet3 = Meet(name="WVAL League Practice Meet #3", date="May 8, 2019")
     meet4 = Meet(name="Santa Clara County Middle School Championships",
                  date="May 15, 2019")
     meet5 = Meet(name="Central Coast Section Middle School Championships",
                  date="May 31, 2019")
     db.session.add_all([meet1, meet2, meet3, meet4, meet5])
     db.session.commit()
     self.assertEqual(Meet.query.count(), 5)
    def setUp(self):
        setup_test_app_db()
        db.create_all()
        self.client = app.test_client()

        TmsApp()
        self.meet = Meet.init_meet(EXAMPLE_MEETS[0])
 def init_small_meet_with_div_event_orders(self):
     meet = Meet.init_meet({
         'name': 'TestMeet',
         'date': "August 5, 2018",
         'division_order': ['7F', '7M'],
         'event_order': ['PV', '200M', '4x400M']
     })
示例#4
0
def do_new_meet_form():
    # # Get form variables
    mi = {}
    mi['name'] = request.form["name"]
    mi['date'] = request.form["date"]
    mi['description'] = request.form.get("description")
    mi['host_school_id'] = session['user_school_id']
    mi['max_entries_per_athlete'] = int(
        request.form.get("max_entries_per_athlete", 4))
    mi['max_relays_per_athlete'] = int(
        request.form.get("max_relays_per_athlete", 2))
    mi['max_teammates_per_event'] = int(
        request.form.get("max_team_entries_per_event", 12))
    mi['max_heats_per_mde'] = int(request.form.get("max_heats_per_mde", 3))
    mi['ev_code_list'] = request.form.get("ev_code_list", DEFAULT_EVENT_ORDER)
    mi['div_code_list'] = request.form.get("div_code_list",
                                           DEFAULT_DIVISION_ORDER)
    # TODO
    # seeding tiebreakers
    # heat assignment method
    # lane/position assignment method
    meet = Meet.init_meet(mi)
    meet.status = "Unpublished"
    flash("New meet created!", "success")
    return (redirect(url_for('show_meet_detail', meet_id=meet.id)))
    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")
    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")
    def test_init_all_meets(self):
        for meet_info in EXAMPLE_MEETS:
            meet = Meet.init_meet(meet_info)

        self.assertEqual(
            len(EXAMPLE_MEETS) - 1,
            Meet.query.filter(Meet.name.like("%PCAL%")).count())
        q = Meet.query.filter_by(status="Unpublished")
        self.assertEqual(q.count(), 1)
        self.assertEqual(q.first().name, "Unpublished Meet")
 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))
 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()
示例#10
0
    def test_create_meet_with_host_school(self):
        meet1 = Meet(name="WVAL League Practice Meet #1",
                     date="April 15, 2019")
        school1 = School(name="RJ Fisher Middle School",
                         code="RJFM",
                         city="Los Gatos",
                         state="CA")
        meet1.host_school = school1
        db.session.add(meet1)
        db.session.commit()

        m = Meet.query.first()
        self.assertEqual(m.status, "Unpublished")
        # test relationship from meet to host_school
        self.assertEqual(m.host_school.code, "RJFM")

        sch = School.query.filter_by(code="RJFM").one()
        self.assertTrue(sch)
        self.assertEqual(sch.city, "Los Gatos")
        self.assertEqual(sch.state, "CA")
示例#11
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()
示例#12
0
    def test_create_meet(self):
        meet1 = Meet(name="WVAL League Practice Meet #1",
                     date="April 15, 2019")
        db.session.add(meet1)
        db.session.commit()
        id = meet1.id

        m = Meet.query.get(id)
        self.assertTrue(m)
        self.assertEqual(m.name, "WVAL League Practice Meet #1")
        self.assertEqual(m.status, "Unpublished")
示例#13
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)
示例#14
0
    def test_init_meet_just_gender_divs_1(self):

        meet = Meet.init_meet({
            "name": "Meet with Just a Male and Female Div & 1 event",
            "date": "March 8, 2019",
            "division_order": ["M", "F"],
            "event_order": ["1600M"]
        })
        self.assertEqual(DivOrdering.query.count(), 2)
        self.assertEqual(len(meet.divisions), 2)
        self.assertEqual(meet.divisions[0].code, "M")
        self.assertEqual(meet.divisions[0].name, "Boys")
        self.assertEqual(meet.divisions[1].code, "F")
        self.assertEqual(meet.divisions[1].name, "Girls")

        self.assertEqual(EventOrdering.query.count(), 1)
        self.assertEqual(meet.events[0].name, "1600 Meter")
        self.assertEqual(meet.events[0].code, "1600M")
示例#15
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])
示例#16
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))
示例#17
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")
示例#18
0
    def test_init_meet_just_gender_divs_2(self):
        meet = Meet.init_meet(
            {
                "name": "Meet with Just a Male and Female Div & 1 event",
                "date": "March 8, 2019",
                "division_order": ["M", "F"],
                "event_order": ["1600M"]
            }, )
        self.assertEqual(MeetDivisionEvent.query.count(), 2)

        mdes = MeetDivisionEvent.query.order_by(MeetDivisionEvent.seq_num)

        self.assertEqual(mdes[0].division.code, "M")
        self.assertEqual(mdes[0].division.name, "Boys")
        self.assertEqual(mdes[0].event.name, "1600 Meter")
        self.assertEqual(mdes[0].event.code, "1600M")
        self.assertEqual(mdes[0].seq_num, 1)

        self.assertEqual(mdes[1].division.code, "F")
        self.assertEqual(mdes[1].division.name, "Girls")
        self.assertEqual(mdes[1].event.name, "1600 Meter")
        self.assertEqual(mdes[1].event.code, "1600M")
        self.assertEqual(mdes[1].seq_num, 2)
示例#19
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()
示例#20
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()
示例#21
0
def helper_file_to_meet(example_meet_idx):
    meet_info_dict = EXAMPLE_MEETS[example_meet_idx]
    meet = Meet.init_meet(EXAMPLE_MEETS[example_meet_idx])
    parse_hytek_file(f"seed_data/{meet_info_dict['filename']}", meet)
    meet.host_school_id = meet_info_dict['host_school_id']
示例#22
0
 def test_athlete_missing_grade(self):
     self.meet1 = Meet.init_meet(EXAMPLE_MEETS[0])
     # this file has one athlete record with an empty grade field
     parse_hytek_file("seed_data/HT_test-no-grade.txt", self.meet1)
     # the athlete should not get added to the database
     self.assertEqual(Athlete.query.count(), 0)
示例#23
0
 def test_bad_create_just_date(self):
     meet2 = Meet(date="September 1, 2019")
     db.session.add(meet2)
     with self.assertRaises(IntegrityError):
         db.session.commit()
示例#24
0
 def test_bad_create_just_name(self):
     meet1 = Meet(name="My Meet Name")
     db.session.add(meet1)
     db.session.commit()
     m = Meet.query.filter_by(name="My Meet Name").one()
     self.assertIsNone(m.date)
示例#25
0
 def test_init_meet_thrice(self):
     meet0 = Meet.init_meet(EXAMPLE_MEETS[0])
     meet1 = Meet.init_meet(EXAMPLE_MEETS[1])
     meet2 = Meet.init_meet(EXAMPLE_MEETS[2])
     self.assertEqual(Meet.query.count(), 3)