def step_impl(context, mid):
    model = Annotator.create()
    ctrl = AnnotatorController()
    ctrl.model = model
    context.ctrl = ctrl
    context.model = model
    team_home = Team('Dallas')
    team_away = Team('NewYork')
    match = Match(team_home, team_away)
    ctrl.add_match(match)
    ctrl.get_match(str(mid)).start_match()
    if context.play_team == 'home':
        team = team_home
    else:
        team = team_away
    play = Play(ptype=context.play_type, spec=context.play_spec, team=team,
                descrip=context.play_desc, time=context.play_min)
    ctrl.get_match(str(mid)).add_play(play)
Beispiel #2
0
    def testOne(self):
        ctrl = AnnotatorController()
        msg = "AnnotatorController creation fail."
        self.assertIsInstance(ctrl, AnnotatorController, msg)  # 1.0
        print "AnnotatorController Test Set: 1.0 Success"

        model = Annotator.create()
        ctrl.model = model

        msg = "AnnotatorController model addition fail."
        self.assertEquals(ctrl.model, model)  # 1.1
        print "AnnotatorController Test Set: 1.1 Success"

        match = TestMatch(home='Barcelona',
                          away='Bayern Munich',
                          mid='BRAVSBAY15')

        ctrl.add_match(match)

        msg = "AnnotatorController match addition fail."
        self.assertEquals(model.get_match(match.mid), match)  # 2.0
        print "AnnotatorController Test Set: 2.0 Success"

        match_copy = ctrl.get_match(match.mid)

        msg = "AnnotatorController get match fail."
        self.assertEquals(match_copy, match, msg)  # 2.1
        print "AnnotatorController Test Set: 2.1 Success"

        ctrl.remove_match(match.mid)

        msg = "AnnotatorController match deletion fail."
        self.assertTrue(len(model.matches) == 0, msg)  # 2.2
        print "AnnotatorController Test Set: 2.2 Success"

        ctrl.save()
        model = None
        model = Annotator.load()

        msg = "AnnotatorController save state fail."
        self.assertIsInstance(model, Annotator, msg)  # 2.3
        print "AnnotatorController Test Set: 2.3 Success"