| 1 | use strict; |
|---|
| 2 | use Test::More; |
|---|
| 3 | |
|---|
| 4 | use Net::Google::Spreadsheets; |
|---|
| 5 | |
|---|
| 6 | my ($service, $config); |
|---|
| 7 | BEGIN { |
|---|
| 8 | plan skip_all => 'set TEST_NET_GOOGLE_SPREADSHEETS to run this test' |
|---|
| 9 | unless $ENV{TEST_NET_GOOGLE_SPREADSHEETS}; |
|---|
| 10 | eval "use Config::Pit"; |
|---|
| 11 | plan skip_all => 'This Test needs Config::Pit.' if $@; |
|---|
| 12 | $config = pit_get('google.com', require => { |
|---|
| 13 | 'username' => 'your username', |
|---|
| 14 | 'password' => 'your password', |
|---|
| 15 | } |
|---|
| 16 | ); |
|---|
| 17 | $service = Net::Google::Spreadsheets->new( |
|---|
| 18 | username => $config->{username}, |
|---|
| 19 | password => $config->{password}, |
|---|
| 20 | ); |
|---|
| 21 | my $title = 'test for Net::Google::Spreadsheets'; |
|---|
| 22 | my $sheet = $service->spreadsheet({title => $title}); |
|---|
| 23 | plan skip_all => "test spreadsheet '$title' doesn't exist." unless $sheet; |
|---|
| 24 | plan tests => 10; |
|---|
| 25 | } |
|---|
| 26 | { |
|---|
| 27 | my $title = 'test for Net::Google::Spreadsheets'; |
|---|
| 28 | my $ss = $service->spreadsheet({title => $title}); |
|---|
| 29 | ok $ss; |
|---|
| 30 | isa_ok $ss, 'Net::Google::Spreadsheets::Spreadsheet'; |
|---|
| 31 | is $ss->title, $title; |
|---|
| 32 | like $ss->id, qr{^http://spreadsheets.google.com/feeds/spreadsheets/}; |
|---|
| 33 | isa_ok $ss->author, 'XML::Atom::Person'; |
|---|
| 34 | is $ss->author->email, $config->{username}; |
|---|
| 35 | my $key = $ss->key; |
|---|
| 36 | ok length $key, 'key defined'; |
|---|
| 37 | { |
|---|
| 38 | my $ss2 = $service->spreadsheet({key => $key}); |
|---|
| 39 | ok $ss2; |
|---|
| 40 | isa_ok $ss2, 'Net::Google::Spreadsheets::Spreadsheet'; |
|---|
| 41 | is $ss2->key, $key; |
|---|
| 42 | } |
|---|
| 43 | } |
|---|