forked from arhuman/Net-Whois-RIPE
/
125-AsSet.t
121 lines (100 loc) · 3.91 KB
/
125-AsSet.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
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
use strict;
use warnings;
use Test::More qw( no_plan );
use Test::Exception;
# synchronizes the {error,standard} output of this test.
use IO::Handle;
STDOUT->autoflush(1);
STDERR->autoflush(1);
our $class;
BEGIN { $class = 'Net::Whois::Object::AsSet'; use_ok $class; }
our %tested;
my @lines = <DATA>;
our $object = ( Net::Whois::Object->new(@lines) )[0];
isa_ok $object, $class;
# Non-inherited methods
can_ok $object, qw( as_set descr members mbrs_by_ref remarks tech_c admin_c
notify mnt_by changed source );
# Check if typed attributes are correct
can_ok $object, $object->attributes('mandatory');
can_ok $object, $object->attributes('optional');
# Test 'as_set'
$tested{'as_set'}++;
is( $object->as_set(), 'AS-COM01', 'as-block properly parsed' );
$object->as_set('AS1-AS2');
is( $object->as_set(), 'AS1-AS2', 'as_set properly set' );
# Test 'descr'
$tested{'descr'}++;
is_deeply( $object->descr(), ['A description'], 'descr properly parsed' );
$object->descr('Added descr');
is( $object->descr()->[1], 'Added descr', 'descr properly added' );
# Test 'remarks'
$tested{'remarks'}++;
is_deeply( $object->remarks(), [ '**********************', '* Remarks *', '**********************' ], 'remarks properly parsed' );
$object->remarks('Added remarks');
is( $object->remarks()->[3], 'Added remarks', 'remarks properly added' );
# Test 'members'
$tested{'members'}++;
is_deeply( $object->members(), [ 'AS1', 'AS11', 'AS21', 'AS1211' ], 'members properly parsed' );
$object->members('Added members');
is( $object->members()->[4], 'Added members', 'members properly added' );
# Test 'mbrs_by_ref'
$tested{'mbrs_by_ref'}++;
is_deeply( $object->mbrs_by_ref(), [ 'UNK-MNT', 'UNK2-MNT', ], 'mbrs_by_ref properly parsed' );
$object->mbrs_by_ref('Added mbrs_by_ref');
is( $object->mbrs_by_ref()->[2], 'Added mbrs_by_ref', 'mbrs_by_ref properly added' );
# Test 'admin_c'
$tested{'admin_c'}++;
is_deeply( $object->admin_c(), ['CPY01-RIPE'], 'admin_c properly parsed' );
$object->admin_c('Added admin_c');
is( $object->admin_c()->[1], 'Added admin_c', 'admin_c properly added' );
# Test 'tech_c'
$tested{'tech_c'}++;
is_deeply( $object->tech_c(), [ 'CPY01-RIPE', 'CXXX-RIPE', 'CXXXXX-RIPE' ], 'tech_c properly parsed' );
$object->tech_c('C007-RIPE');
is( $object->tech_c()->[3], 'C007-RIPE', 'tech_c properly added' );
# Test 'notify'
$tested{'notify'}++;
is_deeply( $object->notify(), ['watcher@somewhere.com'], 'notify properly parsed' );
$object->notify('Added notify');
is( $object->notify()->[1], 'Added notify', 'notify properly added' );
# Test 'mnt_by'
$tested{'mnt_by'}++;
is_deeply( $object->mnt_by(), ['THE-MNT'], 'mnt_by properly parsed' );
$object->mnt_by('Added mnt_by');
is( $object->mnt_by()->[1], 'Added mnt_by', 'mnt_by properly added' );
# Test 'changed'
$tested{'changed'}++;
is_deeply( $object->changed(), [ 'someone@somewhere.net 20080422', 'someoneelese@somewere.net 20090429' ], 'changed properly parsed' );
$object->changed('Added changed');
is( $object->changed()->[2], 'Added changed', 'changed properly added' );
# Test 'source'
$tested{'source'}++;
is( $object->source(), 'RIPE # Filtered', 'source properly parsed' );
$object->source('RIPE');
is( $object->source(), 'RIPE', 'source properly set' );
# Common tests
do 't/common.pl';
ok( $tested{common_loaded}, "t/common.pl properly loaded" );
ok( !$@, "Can evaluate t/common.pl ($@)" );
__DATA__
as-set: AS-COM01
descr: A description
remarks: **********************
remarks: * Remarks *
remarks: **********************
members: AS1
members: AS11
members: AS21
members: AS1211
mbrs-by-ref: UNK-MNT
mbrs-by-ref: UNK2-MNT
admin-c: CPY01-RIPE
tech-c: CPY01-RIPE
tech-c: CXXX-RIPE
tech-c: CXXXXX-RIPE
notify: watcher@somewhere.com
mnt-by: THE-MNT
changed: someone@somewhere.net 20080422
changed: someoneelese@somewere.net 20090429
source: RIPE # Filtered