File: 02-flickr_api.t

package info (click to toggle)
libflickr-api-perl 1.29-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 464 kB
  • sloc: perl: 1,471; makefile: 22
file content (81 lines) | stat: -rw-r--r-- 2,006 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use strict;
use warnings;
use Test::More tests => 15;
use File::Temp ();

use Flickr::API;
########################################################
#
# create a generic flickr api with oauth consumer object
#

my $key    = 'My_Made_up_Key';
my $secret = 'My_little_secret';

my $api = Flickr::API->new({
						 'key'    => $key,
						 'api_secret' => $secret,
						});

isa_ok($api, 'Flickr::API');
is($api->is_oauth, 0, 'Does Flickr::API object identify as Flickr authentication');

is($api->api_type, 'flickr', 'Does Flickr::API object correctly specify its type as flickr');

########################################################
#
# make sure it returns the required api params
#

my %config = $api->export_config();

is($config{'api_key'}, $key,
   'Did export_config return the api_key');

is ($config{'key'}, undef,
    'Did constructor remove the older key in favor of api_key');

is($config{'api_secret'}, $secret,
   'Did export_config return the api secret');

is ($config{'secret'}, undef,
    'Did constructor remove the older secret in favor of api_secret');

is($config{'frob'}, undef,
   'Did export_config return undef for undefined frob');

is($config{'token'}, undef,
   'Did export_config return undef for undefined token');


########################################################
#
#
#

my $FH    = File::Temp->new();
my $config_file = $FH->filename;

$api->export_storable_config($config_file);

my $fileflag=0;
if (-r $config_file) { $fileflag = 1; }
is($fileflag, 1, "Did export_storable_config produce a readable config");

my $api2 = Flickr::API->import_storable_config($config_file);

isa_ok($api2, 'Flickr::API');

is($api2->{api_key}, $key, 'were we able to import our api key');

is($api2->{key}, undef, "did we sucessfully shake deprecated 'key' argument");

is($api2->{api_secret}, $secret, 'were we able to import our api secret');

is($api2->{secret}, undef, "did we sucessfully shake deprecated 'secret' argument");

exit;

# Local Variables:
# mode: Perl
# End: