Coverage for bundesliga_tippspiel/db/match_data/Goal.py: 100%

Shortcuts on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

24 statements  

1"""LICENSE 

2Copyright 2017 Hermann Krumrey <hermann@krumreyh.com> 

3 

4This file is part of bundesliga-tippspiel. 

5 

6bundesliga-tippspiel is free software: you can redistribute it and/or modify 

7it under the terms of the GNU General Public License as published by 

8the Free Software Foundation, either version 3 of the License, or 

9(at your option) any later version. 

10 

11bundesliga-tippspiel is distributed in the hope that it will be useful, 

12but WITHOUT ANY WARRANTY; without even the implied warranty of 

13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

14GNU General Public License for more details. 

15 

16You should have received a copy of the GNU General Public License 

17along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>. 

18LICENSE""" 

19 

20from jerrycan.base import db 

21from jerrycan.db.ModelMixin import ModelMixin 

22from bundesliga_tippspiel.db.match_data.Match import Match 

23from bundesliga_tippspiel.db.match_data.Player import Player 

24 

25 

26class Goal(ModelMixin, db.Model): 

27 """ 

28 Model that describes the "goals" SQL table 

29 """ 

30 

31 def __init__(self, *args, **kwargs): 

32 """ 

33 Initializes the Model 

34 :param args: The constructor arguments 

35 :param kwargs: The constructor keyword arguments 

36 """ 

37 super().__init__(*args, **kwargs) 

38 

39 __tablename__ = "goals" 

40 __table_args__ = ( 

41 db.ForeignKeyConstraint( 

42 ("home_team_abbreviation", "away_team_abbreviation", 

43 "league", "season", "matchday"), 

44 (Match.home_team_abbreviation, Match.away_team_abbreviation, 

45 Match.league, Match.season, Match.matchday) 

46 ), 

47 db.ForeignKeyConstraint( 

48 ("player_name", "player_team_abbreviation"), 

49 (Player.name, Player.team_abbreviation) 

50 ) 

51 ) 

52 

53 league: str = db.Column(db.String(255), primary_key=True) 

54 season: int = db.Column(db.Integer, primary_key=True) 

55 matchday: int = db.Column(db.Integer, primary_key=True) 

56 home_team_abbreviation: str = db.Column(db.String(3), primary_key=True) 

57 away_team_abbreviation: str = db.Column(db.String(3), primary_key=True) 

58 home_score: int = db.Column(db.Integer, primary_key=True) 

59 away_score: int = db.Column(db.Integer, primary_key=True) 

60 

61 player_name: str = db.Column(db.String(255), nullable=False) 

62 player_team_abbreviation: str = db.Column(db.String(3), nullable=False) 

63 

64 minute: int = db.Column(db.Integer, nullable=False) 

65 minute_et: int = db.Column(db.Integer, nullable=True, default=0) 

66 own_goal: bool = db.Column(db.Boolean, nullable=False, default=False) 

67 penalty: bool = db.Column(db.Boolean, nullable=False, default=False) 

68 

69 match: Match = db.relationship("Match", overlaps="goals") 

70 player: Player = db.relationship("Player", overlaps="goals")