sportdb-models 1.18.6 → 1.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +0 -106
- data/Rakefile +0 -1
- data/lib/sportdb/deleter.rb +1 -1
- data/lib/sportdb/models.rb +3 -88
- data/lib/sportdb/version.rb +2 -2
- data/test/helper.rb +0 -108
- metadata +2 -122
- data/lib/sportdb/indexers/team.rb +0 -87
- data/lib/sportdb/matcher.rb +0 -31
- 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/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
@@ -1,63 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_reader_from_string.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestReaderFromString < MiniTest::Test
|
13
|
-
|
14
|
-
def setup
|
15
|
-
WorldDb.delete!
|
16
|
-
SportDb.delete!
|
17
|
-
SportDb.read_builtin
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_bl
|
21
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
22
|
-
|
23
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams', 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/2013_14/bl' )
|
30
|
-
eventreader.read()
|
31
|
-
|
32
|
-
bl = Event.find_by_key!( 'at.2013/14' )
|
33
|
-
|
34
|
-
assert_equal 10, bl.teams.count
|
35
|
-
assert_equal 0, bl.rounds.count
|
36
|
-
assert_equal 0, bl.games.count # 36x5 = 180
|
37
|
-
|
38
|
-
|
39
|
-
bl_txt = File.open( "#{SportDb.test_data_path}/at-austria/2013_14/bl.txt", 'r:bom|utf-8' ).read
|
40
|
-
bl_txt_ii = File.open( "#{SportDb.test_data_path}/at-austria/2013_14/bl_ii.txt", 'r:bom|utf-8' ).read
|
41
|
-
|
42
|
-
text_ary = [bl_txt,bl_txt_ii]
|
43
|
-
|
44
|
-
gamereader = GameReader.from_string( bl, text_ary )
|
45
|
-
gamereader.read()
|
46
|
-
|
47
|
-
## fix: add bl.key - allow event_keys too
|
48
|
-
## gamereader = GameReader.from_string( bl.key, text_ary )
|
49
|
-
## gamereader.read()
|
50
|
-
|
51
|
-
|
52
|
-
assert_equal 36, bl.rounds.count
|
53
|
-
assert_equal 180, bl.games.count # 36x5 = 180
|
54
|
-
|
55
|
-
## check if is stable (update will not create new matches and rounds) on second pass/rerun
|
56
|
-
gamereader.read()
|
57
|
-
|
58
|
-
assert_equal 36, bl.rounds.count
|
59
|
-
assert_equal 180, bl.games.count # 36x5 = 180
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
end # class TestReaderFromString
|
data/test/test_round_auto.rb
DELETED
@@ -1,370 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_round_auto.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestRoundAuto < MiniTest::Test
|
13
|
-
|
14
|
-
def setup
|
15
|
-
WorldDb.delete!
|
16
|
-
SportDb.delete!
|
17
|
-
## SportDb.read_builtin
|
18
|
-
|
19
|
-
add_countries
|
20
|
-
end
|
21
|
-
|
22
|
-
def add_countries
|
23
|
-
countries = [
|
24
|
-
['cd', 'Congo DR', 'COD' ],
|
25
|
-
['kr', 'South Korea', 'KOR' ],
|
26
|
-
['au', 'Australia', 'AUS' ],
|
27
|
-
|
28
|
-
['ar', 'Argentina', 'ARG' ],
|
29
|
-
['br', 'Brazil', 'BRA' ],
|
30
|
-
['bo', 'Bolivia', 'BOL' ],
|
31
|
-
['cl', 'Chile', 'CHI' ],
|
32
|
-
['co', 'Colombia', 'COL' ],
|
33
|
-
['uy', 'Uruguay', 'URU' ],
|
34
|
-
['pe', 'Peru', 'PER' ],
|
35
|
-
['py', 'Paraguay', 'PAR' ],
|
36
|
-
|
37
|
-
['mx', 'Mexico', 'MEX' ],
|
38
|
-
['us', 'United States', 'USA' ],
|
39
|
-
['ht', 'Haiti', 'HAI' ],
|
40
|
-
|
41
|
-
['at', 'Austria', 'AUT' ],
|
42
|
-
['be', 'Belgium', 'BEL' ],
|
43
|
-
['fr', 'France', 'FRA' ],
|
44
|
-
['rs', 'Serbia', 'SRB' ],
|
45
|
-
['ro', 'Romania', 'ROU' ],
|
46
|
-
['bg', 'Bulgaria', 'BUL' ],
|
47
|
-
['cz', 'Czech Republic', 'CZE' ],
|
48
|
-
['en', 'England', 'ENG' ],
|
49
|
-
['de', 'Germany', 'GER' ],
|
50
|
-
['hu', 'Hungary', 'HUN' ],
|
51
|
-
['it', 'Italy', 'ITA' ],
|
52
|
-
['ru', 'Russia', 'RUS' ],
|
53
|
-
['es', 'Spain', 'ESP' ],
|
54
|
-
['ch', 'Switzerland', 'SUI' ],
|
55
|
-
['sc', 'Scotland', 'SCO' ],
|
56
|
-
['tr', 'Turkey', 'TUR' ],
|
57
|
-
['nl', 'Netherlands', 'NED' ],
|
58
|
-
['pl', 'Poland', 'POL' ],
|
59
|
-
['se', 'Sweden', 'SWE' ],
|
60
|
-
]
|
61
|
-
|
62
|
-
countries.each do |country|
|
63
|
-
key = country[0]
|
64
|
-
name = country[1]
|
65
|
-
code = country[2]
|
66
|
-
Country.create!( key: key, name: name, code: code, pop: 1, area: 1)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def test_world_cup_1974
|
72
|
-
teamreader = TestTeamReader.from_file( 'world-cup/teams_1974' )
|
73
|
-
teamreader.read()
|
74
|
-
|
75
|
-
assert_equal 16, Team.count
|
76
|
-
|
77
|
-
seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1974' )
|
78
|
-
seasonreader.read()
|
79
|
-
|
80
|
-
assert_equal 1, Season.count
|
81
|
-
|
82
|
-
y = Season.find_by_key!( '1974' )
|
83
|
-
assert_equal '1974', y.title
|
84
|
-
|
85
|
-
leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
|
86
|
-
leaguereader.read()
|
87
|
-
|
88
|
-
assert_equal 1, League.count
|
89
|
-
|
90
|
-
l = League.find_by_key!( 'world' )
|
91
|
-
assert_equal 'World Cup', l.title
|
92
|
-
|
93
|
-
gamereader = TestGameReader.from_file( 'world-cup/1974/cup' )
|
94
|
-
gamereader.read()
|
95
|
-
|
96
|
-
assert_equal 1, Event.count
|
97
|
-
|
98
|
-
w = Event.find_by_key!( 'world.1974' )
|
99
|
-
|
100
|
-
assert_equal 16, w.teams.count
|
101
|
-
assert_equal 38, w.games.count
|
102
|
-
assert_equal 12, w.rounds.count
|
103
|
-
|
104
|
-
rounds_exp = [
|
105
|
-
[1, 'Matchday 1', '1974-06-13', 1], # first group stage
|
106
|
-
[2, 'Matchday 2', '1974-06-14', 3],
|
107
|
-
[3, 'Matchday 3', '1974-06-15', 4],
|
108
|
-
[4, 'Matchday 4', '1974-06-18', 4],
|
109
|
-
[5, 'Matchday 5', '1974-06-19', 4],
|
110
|
-
[6, 'Matchday 6', '1974-06-22', 4],
|
111
|
-
[7, 'Matchday 7', '1974-06-23', 4],
|
112
|
-
[8, 'Matchday 8', '1974-06-26', 4], # second group stage
|
113
|
-
[9, 'Matchday 9', '1974-06-30', 4],
|
114
|
-
[10, 'Matchday 10', '1974-07-03', 4],
|
115
|
-
[11, 'Match for third place', '1974-07-06', 1], # finals
|
116
|
-
[12, 'Final', '1974-07-07', 1],
|
117
|
-
]
|
118
|
-
|
119
|
-
assert_rounds( rounds_exp )
|
120
|
-
|
121
|
-
#########################
|
122
|
-
## 2nd run
|
123
|
-
### try update (e.g. read again - should NOT create new rounds/games/teams)
|
124
|
-
#
|
125
|
-
# note: update only works if rounds get not deleted or added
|
126
|
-
# - (adding for updates works only at the end/tail - not at the beginning or inbetween, for example)
|
127
|
-
|
128
|
-
gamereader = TestGameReader.from_file( 'world-cup/1974/cup' )
|
129
|
-
gamereader.read()
|
130
|
-
|
131
|
-
assert_equal 1, Event.count
|
132
|
-
|
133
|
-
w = Event.find_by_key!( 'world.1974' )
|
134
|
-
|
135
|
-
assert_equal 16, w.teams.count
|
136
|
-
assert_equal 38, w.games.count
|
137
|
-
assert_equal 12, w.rounds.count
|
138
|
-
|
139
|
-
assert_rounds( rounds_exp )
|
140
|
-
|
141
|
-
end # method test_world_cup_1974
|
142
|
-
|
143
|
-
|
144
|
-
def test_world_cup_1954
|
145
|
-
teamreader = TestTeamReader.from_file( 'world-cup/teams_1954' )
|
146
|
-
teamreader.read()
|
147
|
-
|
148
|
-
assert_equal 16, Team.count
|
149
|
-
|
150
|
-
assert_teams( [
|
151
|
-
[ 'bra', 'Brazil', 'BRA' ],
|
152
|
-
[ 'uru', 'Uruguay', 'URU' ],
|
153
|
-
[ 'bel', 'Belgium', 'BEL' ] ] )
|
154
|
-
|
155
|
-
seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1954' )
|
156
|
-
seasonreader.read()
|
157
|
-
|
158
|
-
assert_equal 1, Season.count
|
159
|
-
|
160
|
-
y = Season.find_by_key!( '1954' )
|
161
|
-
assert_equal '1954', y.title
|
162
|
-
|
163
|
-
|
164
|
-
leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
|
165
|
-
leaguereader.read()
|
166
|
-
|
167
|
-
assert_equal 1, League.count
|
168
|
-
|
169
|
-
l = League.find_by_key!( 'world' )
|
170
|
-
assert_equal 'World Cup', l.title
|
171
|
-
|
172
|
-
|
173
|
-
gamereader = TestGameReader.from_file( 'world-cup/1954/cup' )
|
174
|
-
gamereader.read()
|
175
|
-
|
176
|
-
assert_equal 1, Event.count
|
177
|
-
|
178
|
-
w = Event.find_by_key!( 'world.1954' )
|
179
|
-
|
180
|
-
assert_equal 16, w.teams.count
|
181
|
-
assert_equal 26, w.games.count
|
182
|
-
assert_equal 10, w.rounds.count
|
183
|
-
|
184
|
-
rounds_exp = [
|
185
|
-
[1, 'Matchday 1', '1954-06-16', 4],
|
186
|
-
[2, 'Matchday 2', '1954-06-17', 4],
|
187
|
-
[3, 'Matchday 3', '1954-06-19', 4],
|
188
|
-
[4, 'Matchday 4', '1954-06-20', 4],
|
189
|
-
[5, 'Group-2 Play-off', '1954-06-23', 1],
|
190
|
-
[6, 'Group-4 Play-off', '1954-06-23', 1],
|
191
|
-
[7, 'Quarter-finals', '1954-06-26', 4],
|
192
|
-
[8, 'Semi-finals', '1954-06-30', 2],
|
193
|
-
[9, 'Third place match', '1954-07-03', 1],
|
194
|
-
[10, 'Final', '1954-07-04', 1],
|
195
|
-
]
|
196
|
-
|
197
|
-
assert_rounds( rounds_exp )
|
198
|
-
|
199
|
-
end # test_world_cup_1954
|
200
|
-
|
201
|
-
|
202
|
-
def test_world_cup_1930
|
203
|
-
teamreader = TestTeamReader.from_file( 'world-cup/teams_1930' )
|
204
|
-
teamreader.read()
|
205
|
-
|
206
|
-
assert_equal 13, Team.count
|
207
|
-
|
208
|
-
assert_teams( [
|
209
|
-
[ 'arg', 'Argentina', 'ARG' ],
|
210
|
-
[ 'bra', 'Brazil', 'BRA' ],
|
211
|
-
[ 'bel', 'Belgium', 'BEL' ] ] )
|
212
|
-
|
213
|
-
seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1930' )
|
214
|
-
seasonreader.read()
|
215
|
-
|
216
|
-
assert_equal 1, Season.count
|
217
|
-
|
218
|
-
y = Season.find_by_key!( '1930' )
|
219
|
-
assert_equal '1930', y.title
|
220
|
-
|
221
|
-
|
222
|
-
leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
|
223
|
-
leaguereader.read()
|
224
|
-
|
225
|
-
assert_equal 1, League.count
|
226
|
-
|
227
|
-
l = League.find_by_key!( 'world' )
|
228
|
-
assert_equal 'World Cup', l.title
|
229
|
-
|
230
|
-
|
231
|
-
gamereader = TestGameReader.from_file( 'world-cup/1930/cup' )
|
232
|
-
gamereader.read()
|
233
|
-
|
234
|
-
assert_equal 1, Event.count
|
235
|
-
|
236
|
-
w = Event.find_by_key!( 'world.1930' )
|
237
|
-
|
238
|
-
assert_equal 13, w.teams.count
|
239
|
-
assert_equal 18, w.games.count
|
240
|
-
assert_equal 12, w.rounds.count
|
241
|
-
|
242
|
-
rounds_exp = [
|
243
|
-
[1, 'Matchday 1', '1930-07-13', 2],
|
244
|
-
[2, 'Matchday 2', '1930-07-14', 2],
|
245
|
-
[3, 'Matchday 3', '1930-07-15', 1],
|
246
|
-
[4, 'Matchday 4', '1930-07-16', 1],
|
247
|
-
[5, 'Matchday 5', '1930-07-17', 2],
|
248
|
-
[6, 'Matchday 6', '1930-07-18', 1],
|
249
|
-
[7, 'Matchday 7', '1930-07-19', 2],
|
250
|
-
[8, 'Matchday 8', '1930-07-20', 2],
|
251
|
-
[9, 'Matchday 9', '1930-07-21', 1],
|
252
|
-
[10, 'Matchday 10', '1930-07-22', 1],
|
253
|
-
[11, 'Semi-finals', '1930-07-26', 2],
|
254
|
-
[12, 'Final' , '1930-07-30', 1],
|
255
|
-
]
|
256
|
-
|
257
|
-
assert_rounds( rounds_exp )
|
258
|
-
end # method test_world_cup_1930
|
259
|
-
|
260
|
-
|
261
|
-
def test_world_cup_1962
|
262
|
-
teamreader = TestTeamReader.from_file( 'world-cup/teams_1962' )
|
263
|
-
teamreader.read()
|
264
|
-
|
265
|
-
assert_equal 16, Team.count
|
266
|
-
|
267
|
-
assert_teams( [
|
268
|
-
[ 'arg', 'Argentina', 'ARG' ],
|
269
|
-
[ 'bra', 'Brazil', 'BRA' ],
|
270
|
-
[ 'ita', 'Italy', 'ITA' ] ] )
|
271
|
-
|
272
|
-
seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1962' )
|
273
|
-
seasonreader.read()
|
274
|
-
|
275
|
-
assert_equal 1, Season.count
|
276
|
-
|
277
|
-
y = Season.find_by_key!( '1962' )
|
278
|
-
assert_equal '1962', y.title
|
279
|
-
|
280
|
-
|
281
|
-
leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
|
282
|
-
leaguereader.read()
|
283
|
-
|
284
|
-
assert_equal 1, League.count
|
285
|
-
|
286
|
-
l = League.find_by_key!( 'world' )
|
287
|
-
assert_equal 'World Cup', l.title
|
288
|
-
|
289
|
-
|
290
|
-
gamereader = TestGameReader.from_file( 'world-cup/1962/cup' )
|
291
|
-
gamereader.read()
|
292
|
-
|
293
|
-
assert_equal 1, Event.count
|
294
|
-
|
295
|
-
w = Event.find_by_key!( 'world.1962' )
|
296
|
-
|
297
|
-
assert_equal 16, w.teams.count
|
298
|
-
assert_equal 32, w.games.count
|
299
|
-
assert_equal 10, w.rounds.count
|
300
|
-
|
301
|
-
rounds_exp = [
|
302
|
-
[1, 'Matchday 1', '1962-05-30', 4],
|
303
|
-
[2, 'Matchday 2', '1962-05-31', 4],
|
304
|
-
[3, 'Matchday 3', '1962-06-02', 4],
|
305
|
-
[4, 'Matchday 4', '1962-06-03', 4],
|
306
|
-
[5, 'Matchday 5', '1962-06-06', 4],
|
307
|
-
[6, 'Matchday 6', '1962-06-07', 4],
|
308
|
-
[7, 'Quarter-finals', '1962-06-10', 4],
|
309
|
-
[8, 'Semi-finals', '1962-06-13', 2],
|
310
|
-
[9, 'Third place match', '1962-06-16', 1],
|
311
|
-
[10, 'Final' , '1962-06-17', 1],
|
312
|
-
]
|
313
|
-
|
314
|
-
assert_rounds( rounds_exp )
|
315
|
-
|
316
|
-
#########################
|
317
|
-
## 2nd run
|
318
|
-
### try update (e.g. read again - should NOT create new rounds/games/teams)
|
319
|
-
#
|
320
|
-
# note: update only works if rounds get not deleted or added
|
321
|
-
# - (adding for updates works only at the end/tail - not at the beginning or inbetween, for example)
|
322
|
-
|
323
|
-
gamereader = TestGameReader.from_file( 'world-cup/1962/cup' )
|
324
|
-
gamereader.read()
|
325
|
-
|
326
|
-
assert_equal 1, Event.count
|
327
|
-
|
328
|
-
w = Event.find_by_key!( 'world.1962' )
|
329
|
-
|
330
|
-
assert_equal 16, w.teams.count
|
331
|
-
assert_equal 32, w.games.count
|
332
|
-
assert_equal 10, w.rounds.count
|
333
|
-
|
334
|
-
assert_rounds( rounds_exp )
|
335
|
-
|
336
|
-
end # method test_world_cup_1962
|
337
|
-
|
338
|
-
####
|
339
|
-
# helpers
|
340
|
-
|
341
|
-
def assert_rounds( rounds_exp )
|
342
|
-
rounds_exp.each do |round_exp|
|
343
|
-
round = Round.find_by_pos!( round_exp[0] )
|
344
|
-
|
345
|
-
assert_equal round_exp[1], round.title
|
346
|
-
|
347
|
-
if round_exp[2]
|
348
|
-
start_at = Date.parse( round_exp[2] )
|
349
|
-
## puts "round.start_at.class.name: #{round.start_at.class.name}"
|
350
|
-
assert_equal start_at, round.start_at ## check works for date?
|
351
|
-
end
|
352
|
-
|
353
|
-
if round_exp[3]
|
354
|
-
count = round_exp[3]
|
355
|
-
assert_equal( count, round.games.count, "round.games.count #{count} != #{round.games.count} - #{round.title}")
|
356
|
-
end
|
357
|
-
end
|
358
|
-
end # method assert_rounds
|
359
|
-
|
360
|
-
def assert_teams( teams_exp )
|
361
|
-
teams_exp.each do |team_exp|
|
362
|
-
team = Team.find_by_key!( team_exp[0] )
|
363
|
-
|
364
|
-
assert_equal team_exp[1], team.title
|
365
|
-
assert_equal team_exp[2], team.code
|
366
|
-
end
|
367
|
-
end # method assert_teams
|
368
|
-
|
369
|
-
|
370
|
-
end # class TestRoundAuto
|
data/test/test_round_def.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_round_def.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestRoundDef < MiniTest::Test
|
13
|
-
|
14
|
-
|
15
|
-
def test_round_en
|
16
|
-
SportDb.lang.lang = 'en'
|
17
|
-
|
18
|
-
data = [
|
19
|
-
[ 'Matchday 1 | Thu Jun/12',
|
20
|
-
{ pos:1,
|
21
|
-
title: 'Matchday 1',
|
22
|
-
ko: false,
|
23
|
-
start_at: Date.new( 2014, 6, 12 ) }],
|
24
|
-
[ 'Matchday 1 | 12 June',
|
25
|
-
{ pos:1,
|
26
|
-
title: 'Matchday 1',
|
27
|
-
ko: false,
|
28
|
-
start_at: Date.new( 2014, 6, 12 ) }],
|
29
|
-
[ 'Matchday 1 | 13 July',
|
30
|
-
{ pos:1,
|
31
|
-
title: 'Matchday 1',
|
32
|
-
ko: false,
|
33
|
-
start_at: Date.new( 2014, 7, 13 ) }],
|
34
|
-
[ 'Matchday 13 | Tue Jun/24',
|
35
|
-
{ pos: 13,
|
36
|
-
title: 'Matchday 13',
|
37
|
-
ko: false,
|
38
|
-
start_at: Date.new( 2014, 6, 24 ) }],
|
39
|
-
[ '(16) Round of 16 | Sat Jun/28 - Tue Jul/1',
|
40
|
-
{ pos: 16,
|
41
|
-
title: 'Round of 16',
|
42
|
-
ko: true,
|
43
|
-
start_at: Date.new( 2014, 6, 28 ),
|
44
|
-
end_at: Date.new( 2014, 7, 1 ) }],
|
45
|
-
[ '(18) Semi-finals | Tue Jul/8 - Wed Jul/9',
|
46
|
-
{ pos: 18,
|
47
|
-
title: 'Semi-finals',
|
48
|
-
ko: true,
|
49
|
-
start_at: Date.new( 2014, 7, 8 ),
|
50
|
-
end_at: Date.new( 2014, 7, 9 ) }],
|
51
|
-
[ '(19) Match for third place | Sat Jul/12',
|
52
|
-
{ pos: 19,
|
53
|
-
title: 'Match for third place',
|
54
|
-
ko: true,
|
55
|
-
start_at: Date.new( 2014, 7, 12 ) }],
|
56
|
-
[ '(20) Final | Sun Jul/13',
|
57
|
-
{ pos: 20,
|
58
|
-
title: 'Final',
|
59
|
-
ko: true,
|
60
|
-
start_at: Date.new( 2014, 7, 13 ) }] ]
|
61
|
-
|
62
|
-
assert_rounds( data, Date.new( 2014, 6, 12 )) ## starts Jun/12 2014
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
private
|
67
|
-
class Reader
|
68
|
-
include LogUtils::Logging # add logger
|
69
|
-
include SportDb::FixtureHelpers
|
70
|
-
end
|
71
|
-
|
72
|
-
def assert_rounds( data, event_start_at )
|
73
|
-
data.each do |rec|
|
74
|
-
line = rec[0]
|
75
|
-
hash = rec[1]
|
76
|
-
|
77
|
-
start_at, end_at, pos, title, ko = parse_round_def( line, event_start_at )
|
78
|
-
|
79
|
-
assert_equal hash[:pos], pos, "pos expected #{hash[:pos]} is #{pos} in line >#{line}<"
|
80
|
-
assert_equal hash[:title], title
|
81
|
-
assert_equal hash[:ko], ko
|
82
|
-
|
83
|
-
if hash[:start_at]
|
84
|
-
assert_equal hash[:start_at].year, start_at.year
|
85
|
-
assert_equal hash[:start_at].month, start_at.month
|
86
|
-
assert_equal hash[:start_at].day, start_at.day
|
87
|
-
end
|
88
|
-
|
89
|
-
if hash[:end_at]
|
90
|
-
assert_equal hash[:end_at].year, end_at.year
|
91
|
-
assert_equal hash[:end_at].month, end_at.month
|
92
|
-
assert_equal hash[:end_at].day, end_at.day
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def parse_round_def( line, event_start_at )
|
98
|
-
reader = Reader.new
|
99
|
-
|
100
|
-
start_at = reader.find_date!( line, start_at: event_start_at )
|
101
|
-
end_at = reader.find_date!( line, start_at: event_start_at )
|
102
|
-
pos = reader.find_round_pos!( line )
|
103
|
-
title = reader.find_round_def_title!( line )
|
104
|
-
knockout = reader.is_knockout_round?( title ) # NB: use title as input NOT line
|
105
|
-
|
106
|
-
[start_at, end_at, pos, title, knockout]
|
107
|
-
end
|
108
|
-
|
109
|
-
end # class TestRoundDef
|