File: 03-oauth_consumer.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 (70 lines) | stat: -rw-r--r-- 1,706 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
use strict;
use warnings;
use Test::More;
use Storable;

use Flickr::API;

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


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

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

SKIP: {

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

	my $rsp;
	my $ref;

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

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

	$rsp =  $api->execute_method('flickr.test.echo', {format => 'fake'});

  SKIP: {
		skip "skipping error code check, since we couldn't reach the API", 1
		  if $rsp->rc() ne '200';
		is($rsp->error_code(), 111, 'checking the error code for "format not found"');
	}

	$rsp =  $api->execute_method('flickr.reflection.getMethods');
	$ref = $rsp->as_hash();

  SKIP: {
		skip "skipping method call check, since we couldn't reach the API", 1
		  if $rsp->rc() ne '200';
		is($ref->{'stat'}, 'ok', 'Check for ok status from flickr.reflection.getMethods');
	}

	$rsp =  $api->execute_method('flickr.test.echo', { 'foo' => 'barred' } );
	$ref = $rsp->as_hash();


  SKIP: {
		skip "skipping method call check, since we couldn't reach the API", 2
		  if $rsp->rc() ne '200';
		is($ref->{'stat'}, 'ok', 'Check for ok status from flickr.test.echo');
		is($ref->{'foo'}, 'barred', 'Check result from flickr.test.echo');
	}
}


exit;

# Local Variables:
# mode: Perl
# End: