MT#12347 Fix catalyst config getting for tests

But it is unclear why not /etc/ngcp-panel/ngcp_panel.conf

Change-Id: Id57c284069fe52a3bce4d7191122580baa12e927
changes/74/2974/2
Irina Peshinskaya 10 years ago
parent 88abda5664
commit c54c24aabf

@ -37,18 +37,22 @@ my $test_machine = Test::Collection->new(
$test_machine->methods->{collection}->{allowed} = {map {$_ => 1} qw(GET HEAD OPTIONS POST)}; $test_machine->methods->{collection}->{allowed} = {map {$_ => 1} qw(GET HEAD OPTIONS POST)};
$test_machine->methods->{item}->{allowed} = {map {$_ => 1} qw(GET HEAD OPTIONS)}; $test_machine->methods->{item}->{allowed} = {map {$_ => 1} qw(GET HEAD OPTIONS)};
if(!$test_machine->{catalyst_config}->{features}->{faxserver}){ if(!$test_machine->catalyst_config->{features}->{faxserver}){
diag("Faxes feature is not enabled."); $test_machine->catalyst_config->{features}->{faxserver} //= 0;
is($test_machine->catalyst_config->{features}->{faxserver}, 0, "Faxes feature is not enabled.");
done_testing; done_testing;
exit; exit;
} }
$test_machine->DATA_ITEM_STORE($fake_data->process('faxes')); $test_machine->DATA_ITEM_STORE($fake_data->process('faxes'));
{ {
my $uri = $test_machine->normalize_uri('/api/faxserversettings/'.$test_machine->DATA_ITEM->{json}->{subscriber_id}); my $test_machine_aux = Test::Collection->new(name => 'faxserversettings');
my($res,$faxserversettings,$req) = $test_machine->check_item_get($uri); my $uri = $test_machine_aux->get_uri($test_machine->DATA_ITEM->{json}->{subscriber_id});
my($res,$faxserversettings,$req) = $test_machine_aux->check_item_get($uri);
$faxserversettings->{active} = 1; $faxserversettings->{active} = 1;
$faxserversettings->{password} = 'aaa111'; $faxserversettings->{password} = 'aaa111';
$test_machine->request_put($faxserversettings,$uri); $test_machine_aux->request_put($faxserversettings,$uri);
} }
$test_machine->form_data_item(); $test_machine->form_data_item();

@ -7,11 +7,13 @@ use Test::More;
use Moose; use Moose;
use JSON; use JSON;
use LWP::UserAgent; use LWP::UserAgent;
use Config::General;
use HTTP::Request::Common; use HTTP::Request::Common;
use Net::Domain qw(hostfqdn); use Net::Domain qw(hostfqdn);
use URI; use URI;
use URI::Escape; use URI::Escape;
use Clone qw/clone/; use Clone qw/clone/;
use File::Basename;
use Test::HTTPRequestAsCurl; use Test::HTTPRequestAsCurl;
use Data::Dumper; use Data::Dumper;
@ -30,6 +32,8 @@ has 'DEBUG' => (
has 'catalyst_config' => ( has 'catalyst_config' => (
is => 'rw', is => 'rw',
isa => 'HashRef', isa => 'HashRef',
lazy => 1,
builder => 'init_catalyst_config',
); );
has 'panel_config' => ( has 'panel_config' => (
is => 'rw', is => 'rw',
@ -165,7 +169,7 @@ sub get_cloned{
} }
return $state; return $state;
} }
sub get_catalyst_config{ sub init_catalyst_config{
my $self = shift; my $self = shift;
my $catalyst_config; my $catalyst_config;
my $panel_config; my $panel_config;
@ -176,8 +180,7 @@ sub get_catalyst_config{
last; last;
} }
} }
$panel_config //= '../ngcp_panel.conf'; $panel_config //= dirname($0).'/../../ngcp_panel.conf';
$catalyst_config = Config::General->new($panel_config);
} else { } else {
#taken 1:1 from /lib/NGCP/Panel.pm #taken 1:1 from /lib/NGCP/Panel.pm
for my $path(qw#/etc/ngcp-panel/ngcp_panel.conf etc/ngcp_panel.conf ngcp_panel.conf#) { for my $path(qw#/etc/ngcp-panel/ngcp_panel.conf etc/ngcp_panel.conf ngcp_panel.conf#) {
@ -186,9 +189,9 @@ sub get_catalyst_config{
last; last;
} }
} }
$panel_config //= 'ngcp_panel.conf'; $panel_config //= dirname($0).'/ngcp_panel.conf';
$catalyst_config = Config::General->new($panel_config);
} }
$catalyst_config = Config::General->new($panel_config);
my %config = $catalyst_config->getall(); my %config = $catalyst_config->getall();
$self->{catalyst_config} = \%config; $self->{catalyst_config} = \%config;
$self->{panel_config} = $panel_config; $self->{panel_config} = $panel_config;
@ -376,7 +379,7 @@ sub get_request_put{
#This is for multipart/form-data cases #This is for multipart/form-data cases
$content = $self->encode_content($content, $self->content_type->{PUT}); $content = $self->encode_content($content, $self->content_type->{PUT});
my $req = POST $uri, my $req = POST $uri,
Content_Type => $self->content_type->{POST}, Content_Type => $self->content_type->{PUT},
$content ? ( Content => $content ) : (); $content ? ( Content => $content ) : ();
$req->method('PUT'); $req->method('PUT');
$req->header('Prefer' => 'return=representation'); $req->header('Prefer' => 'return=representation');

Loading…
Cancel
Save