This repository was archived by the owner on Mar 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgreadusergrp.t
executable file
·58 lines (36 loc) · 1.65 KB
/
greadusergrp.t
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
#!/usr/bin/perl -w
# Test cases realized:
# [x] Read groups and check attributes (detects changed markup)
# [ ]
# [ ]
# [ ]
use diagnostics; # More debugging info
use warnings;
use strict;
use FindBin;
use local::lib "$FindBin::Bin/../lib/local/";
use lib "$FindBin::Bin/../lib/";
use Test::More qw( no_plan );
use List::MoreUtils qw( any firstval );
use_ok( 'Goodscrapes' );
# We should never use caching during real tests:
# We need to test against the most up-to-date markup from Goodreads.com
# Having no cache during development is annoying, tho.
# So we leave a small window:
gsetopt( cache_days => 1 );
print( "Getting groups... " );
my %groups;
greadusergp( from_user_id => '1', # "Otis Chandler" (GR founder)
rh_into => \%groups,
# on_group => sub{},
on_progress => gmeter( 'groups' ));
print( "\n" );
ok( scalar( keys( %groups )) > 70, 'At least 70 groups (3 pages)' ); # Chandler had 127
ok( exists( $groups{8095} ), 'Expected group found via hash-key = Goodreads group ID' )
or BAIL_OUT( "Cannot test group attributes when expected group is missing." );
my $g = $groups{8095};
is( $g->{id}, '8095', 'Group has Goodreads ID' );
is( $g->{name}, 'Goodreads Developers', 'Group has name' );
ok( $g->{num_members} > 1000, 'Group has number of members' );
is( $g->{url}, 'https://www.goodreads.com/group/show/8095', 'Group has URL' );
is( $g->{img_url}, 'https://images.gr-assets.com/groups/1220414390p2/8095.jpg', 'Group has image URL' );