re-enable all_parameteres collection of first connect
[perl-cwmp.git] / t / 20-methods.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 my $debug = shift @ARGV;
6
7 use Test::More tests => 18;
8 use Data::Dump qw/dump/;
9 use Cwd qw/abs_path/;
10 use File::Slurp;
11 use blib;
12
13 #use Devel::LeakTrace::Fast;
14
15 BEGIN {
16         use_ok('CWMP::Methods');
17 }
18
19 ok(my $abs_path = abs_path($0), "abs_path");
20 $abs_path =~ s!/[^/]*$!/!;      #!fix-vim
21
22 ok( my $method = CWMP::Methods->new({ debug => $debug }), 'new' );
23 isa_ok( $method, 'CWMP::Methods' );
24
25 sub check_method {
26         my $command = shift || die "no command?";
27
28         my $state = {
29                 ID => 42,
30         };
31
32         diag "check_method $command",dump( 'state', @_ ) if $debug;
33         ok( my $xml = $method->$command( $state, shift ), "generate method $command" . dump(@_) );
34
35         my $file = "$abs_path/methods/$command.xml";
36
37         if ( ! -e $file ) {
38                 diag "creating $file";
39                 write_file( $file, $xml );
40         }
41
42         my $template_xml = read_file( $file ) || die "can't read template xml $file: $!";
43
44         is( $xml, $template_xml, "compare $file" );
45 }
46
47 check_method( 'InformResponse' );
48 check_method( 'GetRPCMethods' );
49 check_method( 'Reboot' );
50 check_method( 'SetParameterValues', {
51         'InternetGatewayDevice.DeviceInfo.ProvisioningCode' => 'test provision',
52         'InternetGatewayDevice.DeviceInfo.X_000E50_Country' => 42,
53 });
54 check_method( 'GetParameterNames', [ 'InternetGatewayDevice.DeviceInfo.SerialNumber' ] );
55 check_method( 'GetParameterValues', [
56         'InternetGatewayDevice.DeviceInfo.SerialNumber',
57         'InternetGatewayDevice.DeviceInfo.VendorConfigFile.',
58 ]);
59 check_method( 'GetParameterAttributes', [
60         'InternetGatewayDevice.DeviceInfo.SerialNumber'
61 ]);