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->{item}->{allowed} = {map {$_ => 1} qw(GET HEAD OPTIONS)};
if(!$test_machine->{catalyst_config}->{features}->{faxserver}){
diag("Faxes feature is not enabled.");
if(!$test_machine->catalyst_config->{features}->{faxserver}){
$test_machine->catalyst_config->{features}->{faxserver} //= 0;
is($test_machine->catalyst_config->{features}->{faxserver}, 0, "Faxes feature is not enabled.");
done_testing;
exit;
}
$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($res,$faxserversettings,$req) = $test_machine->check_item_get($uri);
my $test_machine_aux = Test::Collection->new(name => 'faxserversettings');
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->{password} = 'aaa111';
$test_machine->request_put($faxserversettings,$uri);
$test_machine_aux->request_put($faxserversettings,$uri);
}
$test_machine->form_data_item();

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

Loading…
Cancel
Save