File: 07-reflection.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 (88 lines) | stat: -rw-r--r-- 2,547 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
82
83
84
85
86
87
88
use strict;
use warnings;
use Test::More;
use Flickr::API::Reflection;

if (defined($ENV{MAKETEST_OAUTH_CFG})) {
    plan( tests => 13 );
}
else {
    plan(skip_all => 'Reflection tests require that MAKETEST_OAUTH_CFG points to a valid config, see README.');
}

my $config_file  = $ENV{MAKETEST_OAUTH_CFG};
my $config_ref;
my $api;

my $fileflag=0;
if (-r $config_file) { $fileflag = 1; }
is($fileflag, 1, "Is the config file: $config_file, readable?");

SKIP: {

    skip "Skipping oauth reflection tests, oauth config isn't there or is not readable", 12
        if $fileflag == 0;

    $api = Flickr::API::Reflection->import_storable_config($config_file);

    isa_ok($api, 'Flickr::API::Reflection');
    is($api->is_oauth, 1, 'Does this Flickr::API::Reflection object identify as OAuth');
    is($api->api_success,  1, 'Did reflection api initialize successful');

    my $methods = $api->methods_list();

  SKIP: {

        skip "Skipping methods_list tests, not able to reach the API or received error", 3,
            if !$api->api_success;

        like($methods->[0], qr/^flickr\.[a-z]+\.[a-zA-Z]+$/, "Does the list appear to have a method");

        my %check = map {$_ => 1} @{$methods};

        is( $check{'flickr.reflection.getMethods'}, 1, 'Was flickr.reflection.getMethods in the methods_list');
        is( $check{'flickr.reflection.getMethodInfo'}, 1, 'Was flickr.reflection.getMethodInfo in the methods_list');

    }

    my $hashmethods = $api->methods_hash();

  SKIP: {

        skip "Skipping methods_hash tests, not able to reach the API or received error", 2,
            if !$api->api_success;

        is( $hashmethods->{'flickr.reflection.getMethods'}, 1,
            'Was flickr.reflection.getMethods in the methods_hash');
        is( $hashmethods->{'flickr.reflection.getMethodInfo'}, 1,
            'Was flickr.reflection.getMethodInfo in the methods_hash');

    }

    my $meth = $api->get_method('flickr.replection.getMethodInfo');

    is( $api->api_success, 0, 'Did we fail on a fake method as expected');

    $meth = $api->get_method('flickr.people.getLimits');

    is( $api->api_success, 1, 'Was flickr.people.getLimits successful as expected');

    $meth = $api->get_method('flickr.reflection.getMethodInfo');

    is( $api->api_success, 1, 'Were we successful as expected');
    is( $meth->{'flickr.reflection.getMethodInfo'}->{argument}->{api_key}->{optional}, 0,
        'Did get method reflect that api_key argument is not optional');



}


exit;

__END__


# Local Variables:
# mode: Perl
# End: