harman28 / atpruby

Ruby wrap for working with Jeff Sackmann's tennis_atp database.
MIT License
0 stars 0 forks source link

Can't get tests to run #1

Closed pdgonzalez872 closed 8 years ago

pdgonzalez872 commented 8 years ago

Hi @harman28! Thanks for working on this. I wanted to contribute and was getting familiar with the project. I tried to follow the setup instructions but things don't seem to be coming together.

I wanted to run the specs for the gem by itself. I followed the directions here. Here is the output:

tennis_atp [psql_support] :> bash setup/PostgreSQL/convert_postgres.sh testing_atp Creating testing_atp dropdb: database removal failed: ERROR: database "testing_atp" does not exist CREATE TABLE ERROR: invalid byte sequence for encoding "UTF8": 0xe3 0xb8 0x52 CONTEXT: COPY players, line 12835 UPDATE 0 Players Imported. CREATE TABLE COPY 1232 COPY 1451 COPY 1681 COPY 2712 COPY 2934 COPY 3837 COPY 3899 COPY 4038 COPY 3871 COPY 4046 COPY 3851 COPY 4003 COPY 3955 COPY 3835 COPY 4105 COPY 3557 COPY 3222 COPY 3395 COPY 3251 COPY 3488 COPY 3733 COPY 3583 COPY 3321 COPY 3727 COPY 3792 COPY 3890 COPY 3938 COPY 3800 COPY 3771 COPY 3623 COPY 3589 COPY 3327 COPY 3364 COPY 3307 COPY 3236 COPY 3214 COPY 3277 COPY 3257 COPY 3257 COPY 3152 COPY 3110 COPY 3074 COPY 3058 COPY 3030 COPY 3025 COPY 2959 COPY 2901 COPY 2958 ERROR: extra data after last expected column CONTEXT: COPY matches, line 2: "2016-M020,Brisbane,Hard,32,A,20160104,300,105683,4,,Milos Raonic,R,196,CAN,25.0212183436,14,2170,103..." COPY 9059 COPY 8720 COPY 9995 COPY 10339 COPY 11853 COPY 12549 COPY 13597 COPY 13170 COPY 13139 COPY 12220 COPY 12816 COPY 12647 COPY 13509 COPY 14168 COPY 15076 COPY 15613 COPY 15466 COPY 16522 COPY 15221 COPY 14818 COPY 16360 COPY 18042 COPY 19742 ERROR: invalid byte sequence for encoding "UTF8": 0xe3 0xa9 0x20 CONTEXT: COPY matches, line 18067 COPY 20361 ERROR: extra data after last expected column CONTEXT: COPY matches, line 2: "2016-M-FU-USA-01A-2016,USA F1,Hard,32,S,20160104,001,105815,1,,Tennys Sandgren,R,,USA,24.4544832307,..." COPY 2914 COPY 2759 COPY 2973 COPY 3007 COPY 2635 COPY 3035 COPY 3317 COPY 3503 COPY 3565 COPY 3751 COPY 4185 COPY 3747 COPY 4185 COPY 4526 COPY 4650 COPY 4991 COPY 7086 COPY 7171 COPY 6809 COPY 6628 COPY 6386 COPY 6441 COPY 6479 COPY 6424 COPY 6811 ERROR: extra data after last expected column CONTEXT: COPY matches, line 2: "2016-5047,Bangkok CH,Hard,32,C,20160104,300,104022,3,,Mikhail Youzhny,R,183,RUS,33.5277207392,127,46..." UPDATE 613616 Matches Imported. CREATE TABLE COPY 920541 COPY 567383 COPY 11043 COPY 266705 COPY 724857 UPDATE 2490529 Rankings Imported. All done.

And then, trying to run rspec:

atpruby [looking_around] :> be rspec

Atpruby Has a version number Scopes for Matches work (FAILED - 1) Associations for Matches work (FAILED - 2) Slam_finals (using union) for Players works (FAILED - 3) Matches method (using union) for Players works (FAILED - 4) H2H methods for Players work (FAILED - 5) Rankings assoc for Players works (FAILED - 6)

Failures:

1) Atpruby Scopes for Matches work Failure/Error: expect(finalists).to include('Federer') expected [] to include "Federer"

./spec/atpruby_spec.rb:10:in `block (2 levels) in <top (required)>'

2) Atpruby Associations for Matches work Failure/Error: winner = Match.in_1969.slams.finals.sample.winner.lastname

 NoMethodError:
   undefined method `lastname' for nil:NilClass
 # ./spec/atpruby_spec.rb:14:in `block (2 levels) in <top (required)>'

3) Atpruby Slam_finals (using union) for Players works Failure/Error: firstfinal = borg.slam_finals.order(:match_date).first.tourney_id

 NoMethodError:
   undefined method `slam_finals' for nil:NilClass
 # ./spec/atpruby_spec.rb:20:in `block (2 levels) in <top (required)>'

4) Atpruby Matches method (using union) for Players works Failure/Error: lastmatch = connors.matches.order(:match_date).last

 NoMethodError:
   undefined method `matches' for nil:NilClass
 # ./spec/atpruby_spec.rb:26:in `block (2 levels) in <top (required)>'

5) Atpruby H2H methods for Players work Failure/Error: lastwinner = borg.h2h_details(mcenroe).order(:match_date).last.winner.lastname

 NoMethodError:
   undefined method `h2h_details' for nil:NilClass
 # ./spec/atpruby_spec.rb:34:in `block (2 levels) in <top (required)>'

6) Atpruby Rankings assoc for Players works Failure/Error: lastyear = lendl.rankings.where(pos:1).order(:ranking_date).last.ranking_date.year

 NoMethodError:
   undefined method `rankings' for nil:NilClass
 # ./spec/atpruby_spec.rb:42:in `block (2 levels) in <top (required)>'

Finished in 0.73969 seconds (files took 1.34 seconds to load) 7 examples, 6 failures

Failed examples:

rspec ./spec/atpruby_spec.rb:8 # Atpruby Scopes for Matches work rspec ./spec/atpruby_spec.rb:13 # Atpruby Associations for Matches work rspec ./spec/atpruby_spec.rb:18 # Atpruby Slam_finals (using union) for Players works rspec ./spec/atpruby_spec.rb:24 # Atpruby Matches method (using union) for Players works rspec ./spec/atpruby_spec.rb:31 # Atpruby H2H methods for Players work rspec ./spec/atpruby_spec.rb:40 # Atpruby Rankings assoc for Players works

I was wondering if you have any insight on this. Please let me know if you do!

Thanks!

harman28 commented 8 years ago

Hi Paulo. Thanks for your interest. The issue seems to be here:

ERROR: invalid byte sequence for encoding "UTF8": 0xe3 0xb8 0x52 CONTEXT: COPY players, line 12835 UPDATE 0 Players Imported.

Since no players are imported, the test cases all fail, since they all depend on players existing. Pretty shoddy testing, I know. Will try and improve that.

As for why the players aren't imported. The _atpplayers.csv in the tennis_atp repo file has some characters that aren't suitable for UTF-8 encoding, so it throws an error, and no players are imported. In fact this happens in a few other files too, and none of those find their way into the db. But I didn't notice this earlier, as there are plenty of match/ranking CSVs, but only one players CSV. Apparently I had corrected the file in my local copy but never thought to push it up.

I've made the required changes to the files in my _utf8encoding branch of the tennis_atp repo. If you merge this with your development branch and rerun the psql-setup script, you should be good to go.

All in all, thanks for that. You've shown me a lot of things I still need to do to make these repos usable. Do let me know if you come across any other mistakes.

harman28 commented 8 years ago

Fixed in master.