File: 09-people.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 (166 lines) | stat: -rw-r--r-- 3,655 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
use strict;
use warnings;
use Test::More;
use Flickr::API::People;

if (defined($ENV{MAKETEST_OAUTH_CFG})) {

    plan( tests => 16 );
}
else {
    plan(skip_all => 'People 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 people tests, oauth config isn't there or is not readable", 7   ##############
        if $fileflag == 0;

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

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

    is(
        $api->is_oauth,
        1,
        'Does this Flickr::API::People object identify as OAuth'
    );

    is(
        $api->api_success,
        1,
        'Did people api initialize successful'
    );

    my $valsflag=0;
    my $values_file;

    if (defined($ENV{MAKETEST_VALUES})) {

        $values_file  = $ENV{MAKETEST_VALUES};
        if (-r $values_file) { $valsflag = 1; }
       
    }


  SKIP: {
        skip "Skipping some people tests, values file isn't there or is not readable", 12   ##########
            if $valsflag == 0;

        is(
            $valsflag,
            1,
            "Is the values file: $values_file, readable?"
        );

        my %peoplevalues = (
            'search_email' => '',
            'search_username'  => '',
        );

        open my $VALUES, "<", $values_file or die;

        while (<$VALUES>) {

            chomp;
            s/\s+//g;
            my ($key,$val) = split(/=/);
            if (defined($peoplevalues{$key})) { $peoplevalues{$key} = $val; }

        }

        isnt(
            $peoplevalues{'search_email'},
            '',
            'Is there an email to search for'
        );

        isnt(
            $peoplevalues{'search_user'},
            '',
            'Is there a userid to search for'
         );

        isnt(
            $api->findByEmail($peoplevalues{'search_email'}),
            '',
            'did we get a username from an email'
        );

        is(
            $api->findByEmail('a-non-existent-email-address@nowhere.noway.nohow.nom'),
            undef,
            'did we fail to get username on bogus email address'
        );

        isnt(
            $api->findByUsername($peoplevalues{'search_username'}),
            '',
            'did we get a username from a username search'
        );

        is(
            $api->findByUsername('a-non-existent-user-name-nom-nom.noway.nohow.nom'),
            undef,
            'did we fail to get username on bogus username search'
        );

        is(
            $api->findByUsername($peoplevalues{'search_username'}),
            $peoplevalues{'search_username'},
            'did we get the correct username from a username search'
        );

        is(
            $api->username,
            $peoplevalues{'search_username'},
            'did we get the correct username from the api object'
        );

        isnt(
            $api->nsid,
            '',
            'did we get and nsid from the username search'
        );

        is(
            ref($api->user),
            'HASH',
            'did we get a user hash from the username search'
        );


        is(
            $api->findByUsername('a-non-existent-user-name-nom-nom.noway.nohow.nom'),
            undef,
            'did we fail to get username on bogus username search'
        );

    } # vals File

} # oauth config


exit;

__END__


# Local Variables:
# mode: Perl
# End: