def setUp(self): db.init(':memory:') classes = [Team, League, Season, Person, Player, PlayerStats] db.create_tables(classes) for class_ in classes: if class_.__name__ not in PMDataObject.deferred_relations: PMDataObject.deferred_relations[class_.__name__] = class_ self.league = League.create(name="Band Battle") self.season = Season.create(league=self.league, start_year=2016, end_year=2017, is_current=True) self.team = Team.create(name="Sex Bob-omb", city="Toronto", skill=90, abbreviation="TOR", league=self.league) self.person = Person.create(forename="Scott", surname="Pilgrim") self.player = Player.create(person=self.person, team=self.team, position="F", scoring_rate=12.0, shot_rate=12.0, ) self.stats = PlayerStats.create(player=self.player, season=self.season, team=self.team)
def generate(self): name = self.name_generator.generate() position = self.position_generator.generate() person = Person.create_from_name(name) person.save() scoring_rate = normal(loc=0.085, scale=0.02) if scoring_rate < 0.0: scoring_rate = 0.0 shot_rate = normal(loc=6.0, scale=2.5) if shot_rate < 0.0: shot_rate = 0.0 return Player.create(person=person, position=position, scoring_rate=scoring_rate, shot_rate=shot_rate)
def setUp(self): db.init(':memory:') classes = [Team, League, Season, PlayerStats, Person, Player] db.create_tables(classes) for class_ in classes: if class_.__name__ not in PMDataObject.deferred_relations: PMDataObject.deferred_relations[class_.__name__] = class_ self.league = League.create(name="NHL") self.team = Team.create(name="Canucks", city="Vancouver", skill=100, abbreviation="VAN", league=self.league) self.person = Person.create_from_name(name=Name(forename = "Cliff", surname = "Ronning")) self.player = Player.create(person=self.person, team = self.team, position = "C", scoring_rate=0.07, shot_rate=6) self.season = Season.create(league=self.league, start_year=2016, end_year=2017, is_current=True)
def setUp(self): db.init(':memory:') db.create_tables([Person]) self.name = Name(forename = "Trevor", surname = "Linden") self.person = Person.create(forename=self.name.forename, surname=self.name.surname)
def test_creation_from_name(self): person2 = Person.create_from_name(self.name) self.assertEqual(person2.forename, self.name.forename) self.assertEqual(person2.surname, self.name.surname)