/[cwmp]/google/trunk/t/20-response.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /google/trunk/t/20-response.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 165 - (hide annotations)
Sun Oct 28 11:11:40 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: application/x-troff
File size: 955 byte(s)
refactore response tests to create response xml files if
they doesn't exist (so, implementing new command consists
of adding one line in 20-response.t, re-run test and check if xml is valid
and commit it :-)
1 dpavlin 32 #!/usr/bin/perl
2     use strict;
3     use warnings;
4    
5     my $debug = shift @ARGV;
6    
7 dpavlin 165 use Test::More tests => 12;
8 dpavlin 32 use Data::Dump qw/dump/;
9 dpavlin 165 use Cwd qw/abs_path/;
10     use File::Slurp;
11 dpavlin 32 use blib;
12    
13     BEGIN {
14     use_ok('CWMP::Response');
15     }
16    
17 dpavlin 165 ok(my $abs_path = abs_path($0), "abs_path");
18     $abs_path =~ s!/[^/]*$!/!; #!fix-vim
19 dpavlin 32
20     ok( my $response = CWMP::Response->new({ debug => $debug }), 'new' );
21     isa_ok( $response, 'CWMP::Response' );
22    
23 dpavlin 165 sub check_response {
24     my $command = shift || die "no command?";
25 dpavlin 32
26 dpavlin 165 ok( my $xml = $response->$command({ ID => 42 }), "generate response for $command" );
27 dpavlin 46
28 dpavlin 165 my $file = "$abs_path/response/$command.xml";
29 dpavlin 45
30 dpavlin 165 if ( ! -e $file ) {
31     diag "creating $file";
32     write_file( $file, $xml );
33     }
34 dpavlin 53
35 dpavlin 165 my $template_xml = read_file( $file ) || die "can't read template xml $file: $!";
36 dpavlin 59
37 dpavlin 165 is( $xml, $template_xml, "compare $command" );
38     }
39    
40     check_response( 'InformResponse' );
41     check_response( 'GetRPCMethods' );
42     check_response( 'Reboot' );
43     check_response( 'GetParameterNames' );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26