sportdb-models 1.18.5 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +27 -145
- data/Rakefile +4 -5
- data/lib/sportdb/models.rb +93 -160
- data/lib/sportdb/{deleter.rb → models/deleter.rb} +4 -10
- data/lib/sportdb/models/formats.rb +23 -0
- data/lib/sportdb/models/models/assoc.rb +38 -0
- data/lib/sportdb/models/{badge.rb → models/badge.rb} +1 -1
- data/lib/sportdb/models/models/event.rb +55 -0
- data/lib/sportdb/models/{forward.rb → models/forward.rb} +3 -3
- data/lib/sportdb/models/{goal.rb → models/goal.rb} +1 -1
- data/lib/sportdb/models/models/ground.rb +16 -0
- data/lib/sportdb/models/{group.rb → models/group.rb} +10 -7
- data/lib/sportdb/models/models/league.rb +20 -0
- data/lib/sportdb/models/{roster.rb → models/lineup.rb} +3 -4
- data/lib/sportdb/models/{game.rb → models/match.rb} +18 -61
- data/lib/sportdb/models/{person.rb → models/person.rb} +0 -0
- data/lib/sportdb/models/{round.rb → models/round.rb} +1 -6
- data/lib/sportdb/models/{season.rb → models/season.rb} +2 -1
- data/lib/sportdb/models/{stage.rb → models/stage.rb} +9 -5
- data/lib/sportdb/models/{stats/alltime_standing_entry.rb → models/stats/alltime_standing.rb} +9 -1
- data/lib/sportdb/models/{stats/event_standing_entry.rb → models/stats/event_standing.rb} +11 -1
- data/lib/sportdb/models/{stats/group_standing_entry.rb → models/stats/group_standing.rb} +10 -1
- data/lib/sportdb/models/models/team.rb +56 -0
- data/lib/sportdb/models/{world → models/world}/city.rb +2 -2
- data/lib/sportdb/models/{world → models/world}/continent.rb +0 -0
- data/lib/sportdb/models/{world → models/world}/country.rb +0 -0
- data/lib/sportdb/models/{world → models/world}/state.rb +0 -0
- data/lib/sportdb/{schema.rb → models/schema.rb} +165 -100
- data/lib/sportdb/models/stats.rb +23 -0
- data/lib/sportdb/models/utils.rb +24 -24
- data/lib/sportdb/{version.rb → models/version.rb} +12 -5
- data/test/helper.rb +10 -114
- data/test/test_changes.rb +38 -38
- data/test/test_cursor.rb +15 -15
- data/test/test_winner.rb +75 -70
- metadata +29 -161
- data/lib/sportdb/calc.rb +0 -279
- data/lib/sportdb/indexers/team.rb +0 -87
- data/lib/sportdb/mapper_teams.rb +0 -24
- data/lib/sportdb/matcher.rb +0 -31
- data/lib/sportdb/models/assoc.rb +0 -106
- data/lib/sportdb/models/assoc_assoc.rb +0 -15
- data/lib/sportdb/models/event.rb +0 -66
- data/lib/sportdb/models/event_ground.rb +0 -15
- data/lib/sportdb/models/event_team.rb +0 -16
- data/lib/sportdb/models/ground.rb +0 -100
- data/lib/sportdb/models/group_team.rb +0 -14
- data/lib/sportdb/models/league.rb +0 -83
- data/lib/sportdb/models/stage_team.rb +0 -14
- data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
- data/lib/sportdb/models/stats/event_standing.rb +0 -55
- data/lib/sportdb/models/stats/group_standing.rb +0 -50
- data/lib/sportdb/models/team.rb +0 -119
- data/lib/sportdb/models/team_compat.rb +0 -64
- data/lib/sportdb/patterns.rb +0 -37
- data/lib/sportdb/pretty_printer.rb +0 -175
- data/lib/sportdb/reader.rb +0 -132
- data/lib/sportdb/reader_file.rb +0 -131
- data/lib/sportdb/reader_zip.rb +0 -172
- data/lib/sportdb/readers/assoc.rb +0 -54
- data/lib/sportdb/readers/event.rb +0 -253
- data/lib/sportdb/readers/event_meta.rb +0 -133
- data/lib/sportdb/readers/event_table.rb +0 -196
- data/lib/sportdb/readers/game.rb +0 -912
- data/lib/sportdb/readers/ground.rb +0 -53
- data/lib/sportdb/readers/league.rb +0 -54
- data/lib/sportdb/readers/season.rb +0 -83
- data/lib/sportdb/readers/squad_club.rb +0 -201
- data/lib/sportdb/readers/squad_national_team.rb +0 -173
- data/lib/sportdb/readers/team.rb +0 -53
- data/lib/sportdb/rsssf_reader.rb +0 -367
- data/lib/sportdb/standings.rb +0 -178
- data/lib/sportdb/stats.rb +0 -27
- data/lib/sportdb/utils.rb +0 -89
- data/lib/sportdb/utils_date.rb +0 -26
- data/lib/sportdb/utils_goals.rb +0 -20
- data/lib/sportdb/utils_group.rb +0 -63
- data/lib/sportdb/utils_map.rb +0 -44
- data/lib/sportdb/utils_round.rb +0 -165
- data/lib/sportdb/utils_scores.rb +0 -17
- data/lib/sportdb/utils_teams.rb +0 -48
- data/test/data/at-austria/2013_14/bl.txt +0 -227
- data/test/data/at-austria/2013_14/bl.yml +0 -30
- data/test/data/at-austria/2013_14/bl_ii.txt +0 -154
- data/test/data/at-austria/2013_14/el.txt +0 -4
- data/test/data/at-austria/2013_14/el.yml +0 -25
- data/test/data/at-austria/2013_14/squads/austria.txt +0 -40
- data/test/data/at-austria/2013_14/squads/salzburg.txt +0 -35
- data/test/data/at-austria/2014_15/1-bundesliga-ii.txt +0 -158
- data/test/data/at-austria/2014_15/1-bundesliga.yml +0 -18
- data/test/data/at-austria/2015_16/1-bundesliga-v2.conf.txt +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga-v2.yml +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga.conf.txt +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga.yml +0 -24
- data/test/data/at-austria/2015_16/cup.yml +0 -77
- data/test/data/at-austria/leagues.txt +0 -11
- data/test/data/at-austria/teams.txt +0 -68
- data/test/data/at-austria/teams_2.txt +0 -21
- data/test/data/csv/de-2013-14--1-bundesliga.txt +0 -307
- data/test/data/de-deutschland/2013-14/1-bundesliga.yml +0 -26
- data/test/data/de-deutschland/leagues.txt +0 -4
- data/test/data/de-deutschland/teams.txt +0 -53
- data/test/data/eng-england/2015-16/1-premierleague-v2.yml +0 -2
- data/test/data/eng-england/2015-16/1-premierleague.yml +0 -5
- data/test/data/national-teams/assocs.txt +0 -231
- data/test/data/national-teams/europe/assocs.txt +0 -13
- data/test/data/national-teams/europe/teams.txt +0 -13
- data/test/data/national-teams/north-america/assocs.txt +0 -10
- data/test/data/national-teams/north-america/teams.txt +0 -7
- data/test/data/national-teams/teams.txt +0 -19
- data/test/data/players/europe/at-austria/players.txt +0 -45
- data/test/data/players/europe/de-deutschland/players.txt +0 -41
- data/test/data/players/south-america/br-brazil/players.txt +0 -51
- data/test/data/rsssf/at-2014-15--1-bundesliga.txt +0 -339
- data/test/data/rsssf/at-2015-16--1-bundesliga.txt +0 -18
- data/test/data/world-cup/1930/cup.txt +0 -71
- data/test/data/world-cup/1930/cup.yml +0 -23
- data/test/data/world-cup/1930/cup_goals.txt +0 -47
- data/test/data/world-cup/1930/cup_goals.yml +0 -23
- data/test/data/world-cup/1954/cup.txt +0 -90
- data/test/data/world-cup/1954/cup.yml +0 -30
- data/test/data/world-cup/1962/cup.txt +0 -86
- data/test/data/world-cup/1962/cup.yml +0 -32
- data/test/data/world-cup/1974/cup.yml +0 -35
- data/test/data/world-cup/1974/cup_finals.txt +0 -14
- data/test/data/world-cup/1974/cup_i.txt +0 -55
- data/test/data/world-cup/1974/cup_ii.txt +0 -34
- data/test/data/world-cup/2014/cup.txt +0 -5
- data/test/data/world-cup/2014/cup.yml +0 -54
- data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
- data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
- data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
- data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
- data/test/data/world-cup/leagues.txt +0 -5
- data/test/data/world-cup/seasons_1930.txt +0 -4
- data/test/data/world-cup/seasons_1954.txt +0 -4
- data/test/data/world-cup/seasons_1962.txt +0 -4
- data/test/data/world-cup/seasons_1974.txt +0 -5
- data/test/data/world-cup/teams_1930.txt +0 -26
- data/test/data/world-cup/teams_1954.txt +0 -30
- data/test/data/world-cup/teams_1962.txt +0 -29
- data/test/data/world-cup/teams_1974.txt +0 -29
- data/test/test_assoc_reader.rb +0 -199
- data/test/test_event_meta_reader.rb +0 -47
- data/test/test_event_reader.rb +0 -64
- data/test/test_event_table_reader.rb +0 -57
- data/test/test_goals.rb +0 -107
- data/test/test_indexer_team.rb +0 -34
- data/test/test_load.rb +0 -61
- data/test/test_pp.rb +0 -35
- data/test/test_reader.rb +0 -88
- data/test/test_reader_from_string.rb +0 -63
- data/test/test_round_auto.rb +0 -370
- data/test/test_round_def.rb +0 -109
- data/test/test_round_header.rb +0 -183
- data/test/test_rsssf_reader.rb +0 -76
- data/test/test_squad_club_reader.rb +0 -76
- data/test/test_squad_national_team_reader.rb +0 -116
- data/test/test_standings.rb +0 -279
- data/test/test_standings_ii.rb +0 -46
- data/test/test_utils.rb +0 -124
data/test/test_round_header.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
require 'helper'
|
5
|
-
|
6
|
-
class TestRoundHeader < MiniTest::Test
|
7
|
-
|
8
|
-
|
9
|
-
def test_round_en
|
10
|
-
SportDb.lang.lang = 'en'
|
11
|
-
|
12
|
-
data = [
|
13
|
-
[ "2. Round / Group B",
|
14
|
-
{ pos:2,
|
15
|
-
title: '2. Round',
|
16
|
-
group_pos: 2,
|
17
|
-
group_title: 'Group B',
|
18
|
-
ko: false } ],
|
19
|
-
|
20
|
-
[ "(1) Matchday P.1 / 1st Leg // January 22-24",
|
21
|
-
{ pos:1,
|
22
|
-
title: 'Matchday P.1 / 1st Leg',
|
23
|
-
title2: 'January 22-24',
|
24
|
-
ko: false } ],
|
25
|
-
|
26
|
-
[ "(4) Matchday 2 / Group 1 // February 19-21",
|
27
|
-
{ pos:4,
|
28
|
-
title: 'Matchday 2',
|
29
|
-
title2: 'February 19-21',
|
30
|
-
group_pos: 1,
|
31
|
-
group_title: 'Group 1',
|
32
|
-
ko: false } ],
|
33
|
-
|
34
|
-
[ "(13) Round of 16 / 1st Leg // April 25, May 1-3",
|
35
|
-
{ pos:13,
|
36
|
-
title: 'Round of 16 / 1st Leg',
|
37
|
-
title2: 'April 25, May 1-3',
|
38
|
-
ko: false } ], # NB: 1st Leg is NOT k.o. (only 2nd Leg)
|
39
|
-
|
40
|
-
[ "(14) Round of 16 / 2nd Leg // May 8-10",
|
41
|
-
{ pos:14,
|
42
|
-
title: 'Round of 16 / 2nd Leg',
|
43
|
-
title2: 'May 8-10',
|
44
|
-
ko: true }],
|
45
|
-
|
46
|
-
[ "(4) Match for fifth place",
|
47
|
-
{ pos:4,
|
48
|
-
title: 'Match for fifth place',
|
49
|
-
ko: true }],
|
50
|
-
|
51
|
-
[ "(5) Match for third place",
|
52
|
-
{ pos:5,
|
53
|
-
title: 'Match for third place',
|
54
|
-
ko: true }],
|
55
|
-
|
56
|
-
[ "(1) Play-off for quarter-finals",
|
57
|
-
{ pos:1,
|
58
|
-
title: 'Play-off for quarter-finals',
|
59
|
-
ko: true }],
|
60
|
-
|
61
|
-
[ "(1) Play-off 1st Leg // 11–15 October",
|
62
|
-
{ pos:1,
|
63
|
-
title: 'Play-off 1st Leg',
|
64
|
-
title2: '11–15 October',
|
65
|
-
ko: false } ],
|
66
|
-
|
67
|
-
[ "(2) Play-off 2nd Leg // 15-19 November",
|
68
|
-
{ pos:2,
|
69
|
-
title: 'Play-off 2nd Leg',
|
70
|
-
title2: '15-19 November',
|
71
|
-
ko: true } ],
|
72
|
-
]
|
73
|
-
|
74
|
-
assert_rounds( data )
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
def test_finals_en
|
79
|
-
SportDb.lang.lang = 'en'
|
80
|
-
|
81
|
-
data = [
|
82
|
-
[ '(4) Quarter-finals',
|
83
|
-
{ pos: 4,
|
84
|
-
title: 'Quarter-finals',
|
85
|
-
ko: true } ],
|
86
|
-
|
87
|
-
[ '(5) Semi-finals',
|
88
|
-
{ pos: 5,
|
89
|
-
title: 'Semi-finals',
|
90
|
-
ko: true } ],
|
91
|
-
|
92
|
-
[ '(6) Final',
|
93
|
-
{ pos: 6,
|
94
|
-
title: 'Final',
|
95
|
-
ko: true } ] ]
|
96
|
-
|
97
|
-
assert_rounds( data )
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
def test_round_es
|
102
|
-
SportDb.lang.lang = 'es'
|
103
|
-
|
104
|
-
data = [
|
105
|
-
[ 'Jornada 2 // 27, 28 y 29 de julio',
|
106
|
-
{ pos:2,
|
107
|
-
title: 'Jornada 2',
|
108
|
-
title2: '27, 28 y 29 de julio',
|
109
|
-
ko: false } ],
|
110
|
-
|
111
|
-
[ '(18) Cuartos de Final / Ida // 14/15 de noviembre',
|
112
|
-
{ pos:18,
|
113
|
-
title: 'Cuartos de Final / Ida',
|
114
|
-
title2: '14/15 de noviembre',
|
115
|
-
ko: false } ],
|
116
|
-
|
117
|
-
[ '(19) Cuartos de Final / Vuelta // 17/18 de noviembre',
|
118
|
-
{ pos:19,
|
119
|
-
title: 'Cuartos de Final / Vuelta',
|
120
|
-
title2: '17/18 de noviembre',
|
121
|
-
ko: true } ]]
|
122
|
-
|
123
|
-
assert_rounds( data )
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
def test_round_de
|
128
|
-
SportDb.lang.lang = 'de'
|
129
|
-
|
130
|
-
data = [
|
131
|
-
[ 'Spieltag 5 / Gruppe A // Di./Mi., 20.+21. Nov 2012',
|
132
|
-
{ pos: 5,
|
133
|
-
title: 'Spieltag 5',
|
134
|
-
title2: 'Di./Mi., 20.+21. Nov 2012',
|
135
|
-
group_pos: 1,
|
136
|
-
group_title: 'Gruppe A',
|
137
|
-
ko: false } ],
|
138
|
-
|
139
|
-
[ '(8) Achtelfinale Rückspiele // Di./Mi., 5.+6./12.+13. Mär 2013',
|
140
|
-
{ pos: 8,
|
141
|
-
title: 'Achtelfinale Rückspiele',
|
142
|
-
title2: 'Di./Mi., 5.+6./12.+13. Mär 2013',
|
143
|
-
ko: true } ]]
|
144
|
-
|
145
|
-
assert_rounds( data )
|
146
|
-
end
|
147
|
-
|
148
|
-
|
149
|
-
private
|
150
|
-
class Reader
|
151
|
-
include LogUtils::Logging # add logger
|
152
|
-
include SportDb::FixtureHelpers
|
153
|
-
end
|
154
|
-
|
155
|
-
def assert_rounds( data )
|
156
|
-
data.each do |rec|
|
157
|
-
line = rec[0]
|
158
|
-
hash = rec[1]
|
159
|
-
|
160
|
-
pos, title, title2, group_pos, group_title, ko = parse_round_header( line )
|
161
|
-
|
162
|
-
assert_equal hash[:pos], pos, "pos expected #{hash[:pos]} is #{pos} in line >#{line}<"
|
163
|
-
assert_equal hash[:title], title
|
164
|
-
assert_equal hash[:title2], title2
|
165
|
-
assert_equal hash[:ko], ko
|
166
|
-
assert_equal( hash[:group_pos], group_pos, "group_pos expected #{hash[:group_pos]} is #{group_pos} in line >#{line}<" ) if hash[:group_pos]
|
167
|
-
assert_equal( hash[:group_title], group_title) if hash[:group_title]
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def parse_round_header( line )
|
172
|
-
reader = Reader.new
|
173
|
-
|
174
|
-
title2 = reader.find_round_header_title2!( line )
|
175
|
-
group_title, group_pos = reader.find_group_title_and_pos!( line )
|
176
|
-
pos = reader.find_round_pos!( line )
|
177
|
-
title = reader.find_round_header_title!( line )
|
178
|
-
knockout = reader.is_knockout_round?( title ) # NB: use title as input NOT line
|
179
|
-
|
180
|
-
[pos, title, title2, group_pos, group_title, knockout]
|
181
|
-
end
|
182
|
-
|
183
|
-
end # class TestRoundHeader
|
data/test/test_rsssf_reader.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_rsssf_reader.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestRsssfReader < MiniTest::Test
|
11
|
-
|
12
|
-
def setup
|
13
|
-
WorldDb.delete!
|
14
|
-
SportDb.delete!
|
15
|
-
SportDb.read_builtin
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_bl_2016
|
19
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
20
|
-
|
21
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
|
22
|
-
teamreader.read()
|
23
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams_2', country_id: at.id )
|
24
|
-
teamreader.read()
|
25
|
-
|
26
|
-
leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
|
27
|
-
leaguereader.read()
|
28
|
-
|
29
|
-
eventreader = TestEventReader.from_file( 'at-austria/2015_16/1-bundesliga' )
|
30
|
-
eventreader.read
|
31
|
-
|
32
|
-
assert true ## if we get here; assume everything ok
|
33
|
-
|
34
|
-
text = File.read_utf8( "#{SportDb.test_data_path}/rsssf/at-2015-16--1-bundesliga.txt" )
|
35
|
-
|
36
|
-
## bl = Event.find_by_key!( 'at.2015/16' )
|
37
|
-
|
38
|
-
r = SportDb::RsssfGameReader.from_string( 'at.2015/16', text )
|
39
|
-
r.read
|
40
|
-
|
41
|
-
## assert_equal 10, bl.teams.count
|
42
|
-
## assert_equal 36, bl.rounds.count
|
43
|
-
## assert_equal 180, bl.games.count # 36x5 = 180
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_bl_2015
|
47
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
48
|
-
|
49
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
|
50
|
-
teamreader.read()
|
51
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams_2', country_id: at.id )
|
52
|
-
teamreader.read()
|
53
|
-
|
54
|
-
leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
|
55
|
-
leaguereader.read()
|
56
|
-
|
57
|
-
eventreader = TestEventReader.from_file( 'at-austria/2014_15/1-bundesliga' )
|
58
|
-
eventreader.read
|
59
|
-
|
60
|
-
assert true ## if we get here; assume everything ok
|
61
|
-
|
62
|
-
text = File.read_utf8( "#{SportDb.test_data_path}/rsssf/at-2014-15--1-bundesliga.txt" )
|
63
|
-
|
64
|
-
## bl = Event.find_by_key!( 'at.2014/15' )
|
65
|
-
|
66
|
-
r = SportDb::RsssfGameReader.from_string( 'at.2014/15', text )
|
67
|
-
r.read
|
68
|
-
|
69
|
-
## assert_equal 10, bl.teams.count
|
70
|
-
## assert_equal 36, bl.rounds.count
|
71
|
-
## assert_equal 180, bl.games.count # 36x5 = 180
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
end # class TestRsssfReader
|
76
|
-
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_squad_club_reader.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestSquadClubReaderXX < MiniTest::Test # note: TestSquadClubReader alreay defined, thus, add xx
|
13
|
-
|
14
|
-
def setup
|
15
|
-
WorldDb.delete!
|
16
|
-
SportDb.delete!
|
17
|
-
PersonDb.delete!
|
18
|
-
|
19
|
-
add_bl
|
20
|
-
end
|
21
|
-
|
22
|
-
def add_bl
|
23
|
-
SportDb.read_builtin # add 2013/14 season
|
24
|
-
|
25
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
26
|
-
|
27
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
|
28
|
-
teamreader.read()
|
29
|
-
|
30
|
-
leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
|
31
|
-
leaguereader.read()
|
32
|
-
|
33
|
-
## check/fix: is country_id more_attribs needed? why? why not?
|
34
|
-
gamereader = TestGameReader.from_file( 'at-austria/2013_14/bl', country_id: at.id )
|
35
|
-
gamereader.read()
|
36
|
-
|
37
|
-
bl = Event.find_by_key!( 'at.2013/14' )
|
38
|
-
|
39
|
-
assert_equal 10, bl.teams.count
|
40
|
-
assert_equal 36, bl.rounds.count
|
41
|
-
assert_equal 180, bl.games.count # 36x5 = 180
|
42
|
-
|
43
|
-
## add players
|
44
|
-
## -- read persons
|
45
|
-
## personreader = PersonReader.new( SportDb.test_data_path )
|
46
|
-
## personreader.read( 'players/europe/at-austria/players', country_id: at.id )
|
47
|
-
|
48
|
-
## assert_equal 30, Person.count
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def test_austria
|
53
|
-
austria = Team.find_by_key!( 'austria' )
|
54
|
-
|
55
|
-
event = Event.find_by_key!( 'at.2013/14' )
|
56
|
-
|
57
|
-
reader = TestClubSquadReader.from_file( 'at-austria/2013_14/squads/austria', team_id: austria.id, event_id: event.id )
|
58
|
-
reader.read()
|
59
|
-
|
60
|
-
assert_equal 28, Roster.count
|
61
|
-
end # method test_br
|
62
|
-
|
63
|
-
|
64
|
-
def test_salzburg
|
65
|
-
salzburg = Team.find_by_key!( 'salzburg' )
|
66
|
-
|
67
|
-
event = Event.find_by_key!( 'at.2013/14' )
|
68
|
-
|
69
|
-
reader = TestClubSquadReader.from_file( 'at-austria/2013_14/squads/salzburg', team_id: salzburg.id, event_id: event.id )
|
70
|
-
reader.read()
|
71
|
-
|
72
|
-
assert_equal 27, Roster.count
|
73
|
-
end # method test_salzburg
|
74
|
-
|
75
|
-
|
76
|
-
end # class TestSquadClubReader
|
@@ -1,116 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_squad_national_team_reader.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestSquadNationalTeamReader < MiniTest::Test
|
13
|
-
|
14
|
-
def setup
|
15
|
-
WorldDb.delete!
|
16
|
-
SportDb.delete!
|
17
|
-
PersonDb.delete!
|
18
|
-
|
19
|
-
add_world_cup_2014
|
20
|
-
end
|
21
|
-
|
22
|
-
def add_world_cup_2014
|
23
|
-
SportDb.read_builtin # add 2014 season
|
24
|
-
|
25
|
-
leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
|
26
|
-
leaguereader.read()
|
27
|
-
|
28
|
-
assert_equal 1, League.count
|
29
|
-
|
30
|
-
l = League.find_by_key!( 'world' )
|
31
|
-
assert_equal 'World Cup', l.title
|
32
|
-
|
33
|
-
gamereader = TestGameReader.from_file( 'world-cup/2014/cup' )
|
34
|
-
gamereader.read()
|
35
|
-
|
36
|
-
assert_equal 1, Event.count
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_br
|
40
|
-
br = Country.create!( key: 'br', title: 'Brazil', code: 'BRA', pop: 1, area: 1)
|
41
|
-
|
42
|
-
## read persons
|
43
|
-
## personreader = PersonReader.new( SportDb.test_data_path )
|
44
|
-
## personreader.read( 'players/south-america/br-brazil/players', country_id: br.id )
|
45
|
-
##
|
46
|
-
## assert_equal 30, Person.count
|
47
|
-
|
48
|
-
bra = Team.create!( key: 'bra', title: 'Brazil', code: 'BRA', country_id: br.id )
|
49
|
-
|
50
|
-
|
51
|
-
event = Event.find_by_key!( 'world.2014' )
|
52
|
-
|
53
|
-
reader = TestNationalTeamSquadReader.from_file( 'world-cup/2014/squads/br-brazil', team_id: bra.id, event_id: event.id )
|
54
|
-
reader.read()
|
55
|
-
|
56
|
-
assert_equal 23, Roster.count
|
57
|
-
end # method test_br
|
58
|
-
|
59
|
-
|
60
|
-
def test_de
|
61
|
-
de = Country.create!( key: 'de', title: 'Germany', code: 'GER', pop: 1, area: 1)
|
62
|
-
|
63
|
-
## read persons
|
64
|
-
## personreader = PersonReader.new( SportDb.test_data_path )
|
65
|
-
## personreader.read( 'players/europe/de-deutschland/players', country_id: de.id )
|
66
|
-
##
|
67
|
-
## assert_equal 27, Person.count
|
68
|
-
|
69
|
-
ger = Team.create!( key: 'ger', title: 'Germany', code: 'GER', country_id: de.id )
|
70
|
-
|
71
|
-
event = Event.find_by_key!( 'world.2014' )
|
72
|
-
|
73
|
-
reader = TestNationalTeamSquadReader.from_file( 'world-cup/2014/squads/de-deutschland', team_id: ger.id, event_id: event.id )
|
74
|
-
reader.read()
|
75
|
-
|
76
|
-
assert_equal 3, Roster.count
|
77
|
-
end # method test_de
|
78
|
-
|
79
|
-
|
80
|
-
def test_uy
|
81
|
-
uy = Country.create!( key: 'uy', title: 'Uruguay', code: 'URU', pop: 1, area: 1)
|
82
|
-
|
83
|
-
assert_equal 0, Person.count
|
84
|
-
assert_equal 0, Roster.count
|
85
|
-
|
86
|
-
uru = Team.create!( key: 'uru', title: 'Uruguay', code: 'URU', country_id: uy.id )
|
87
|
-
|
88
|
-
event = Event.find_by_key!( 'world.2014' )
|
89
|
-
|
90
|
-
reader = TestNationalTeamSquadReader.from_file( 'world-cup/2014/squads/uy-uruguay', team_id: uru.id, event_id: event.id )
|
91
|
-
reader.read()
|
92
|
-
|
93
|
-
assert_equal 23, Roster.count
|
94
|
-
assert_equal 23, Person.count
|
95
|
-
end # method test_uy
|
96
|
-
|
97
|
-
|
98
|
-
def test_jp
|
99
|
-
jp = Country.create!( key: 'jp', title: 'Japan', code: 'JPN', pop: 1, area: 1)
|
100
|
-
|
101
|
-
assert_equal 0, Person.count
|
102
|
-
assert_equal 0, Roster.count
|
103
|
-
|
104
|
-
jpn = Team.create!( key: 'jpn', title: 'Japan', code: 'JPN', country_id: jp.id )
|
105
|
-
|
106
|
-
event = Event.find_by_key!( 'world.2014' )
|
107
|
-
|
108
|
-
reader = TestNationalTeamSquadReader.from_file( 'world-cup/2014/squads/jp-japan', team_id: jpn.id, event_id: event.id )
|
109
|
-
reader.read()
|
110
|
-
|
111
|
-
assert_equal 23, Roster.count
|
112
|
-
assert_equal 23, Person.count
|
113
|
-
end # method test_jp
|
114
|
-
|
115
|
-
|
116
|
-
end # class TestSquadNationalTeamReader
|