1 package FS::part_export::test;
4 use vars qw(%options %info);
6 use base qw(FS::part_export);
8 tie %options, 'Tie::IxHash',
9 'result' => { label => 'Result',
11 options => [ 'success', 'failure', 'exception' ],
14 'errormsg'=> { label => 'Error message',
15 default => 'Test export' },
16 'insert' => { label => 'Insert', type => 'checkbox', default => 1, },
17 'delete' => { label => 'Delete', type => 'checkbox', default => 1, },
18 'replace' => { label => 'Replace',type => 'checkbox', default => 1, },
19 'suspend' => { label => 'Suspend',type => 'checkbox', default => 1, },
20 'unsuspend'=>{ label => 'Unsuspend', type => 'checkbox', default => 1, },
21 'get_dids_npa_select' => { label => 'DIDs by NPA', type => 'checkbox' },
25 'svc' => [ qw(svc_acct svc_broadband svc_phone svc_domain) ],
26 'desc' => 'Test export for development',
27 'options' => \%options,
29 <P>Test export. Do not use this in production systems.</P>
30 <P>This export either always succeeds, always fails (returning an error),
31 or always dies, according to the "Result" option. It does nothing else; the
32 purpose is purely to simulate success or failure within an export module.</P>
33 <P>The checkbox options can be used to turn the export off for certain
34 actions, if this is needed.</P>
35 <P>This export will produce a small set of DIDs, in either Alabama (if the
36 "DIDs by NPA" option is on) or California (if not).</P>
42 $self->run(@_) if $self->option('insert');
47 $self->run(@_) if $self->option('delete');
52 $self->run(@_) if $self->option('replace');
57 $self->run(@_) if $self->option('suspend');
60 sub export_unsuspend {
62 $self->run(@_) if $self->option('unsuspend');
68 my $result = $self->option('result');
69 if ( $result eq 'failure' ) {
70 return $self->option('errormsg');
71 } elsif ( $result eq 'exception' ) {
72 die $self->option('errormsg');
78 sub can_get_dids { 1 }
80 sub get_dids_npa_select {
82 $self->option('get_dids_npa_select') ? 1 : 0;
85 # we don't yet have tollfree
88 'states' => [ 'AK', 'AL' ],
91 'AL' => [ '205', '998', '999' ],
93 '205' => [ 'ALABASTER (205-555-XXXX)', # an NPA-NXX
94 'EMPTY (205-998-XXXX)',
95 'INVALID (205-999-XXXX)',
96 'ALBERTVILLE, AL', # a ratecenter
115 my $dids_by_region = {
116 'states' => [ 'CA', 'CO' ],
117 'CA' => [ 'CALIFORNIA',
134 my $data = $self->get_dids_npa_select ? $dids_by_npa : $dids_by_region;
137 if ( $opt{'exchange'} ) {
138 $key = $opt{'areacode'} . $opt{'exchange'};
140 $key = $opt{'ratecenter'}
146 if ( defined $data->{ $key } ) {
147 return $data->{ $key };
149 die "[test] '$key' is invalid\n";