File: 08-cameras.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 (86 lines) | stat: -rw-r--r-- 2,106 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
use strict;
use warnings;
use Test::More;
use Flickr::API::Cameras;

if (defined($ENV{MAKETEST_OAUTH_CFG})) {
    plan( tests => 12 );
}
else {
    plan(skip_all => 'Cameras 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 $papi;

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

SKIP: {

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

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

    isa_ok($api,  'Flickr::API::Cameras');

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

    my $brands = $api->brands_list();

  SKIP: {

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

        like($brands->[0], qr/^[a-zA-Z]+$/, "Does the list appear to have a brand");

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

        is( $check{'Canon'}, 1, 'Was Canon in the brands_list');
        is( $check{'Olympus'}, 1, 'Was Olympus in the brands_list');

    }

    my $hashcameras = $api->brands_hash();

  SKIP: {

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

        is( $hashcameras->{'Nikon'}, 1,
            'Was Nikon in the cameras_hash');
        is( $hashcameras->{'Olympus'}, 1,
            'Was Olympus in the cameras_hash');

    }

    my $cameras = $api->get_cameras('You_call_THIS_a_camera_Brand');

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

    $cameras = $api->get_cameras('Leica');

    is( $api->api_success, 1, 'Were we successful as expected');

    my @cam_ids = keys(%{$cameras->{'Leica'}});

    ok( $#cam_ids > 0, 'Did we get a list of camera models');

}


exit;

__END__


# Local Variables:
# mode: Perl
# End: