From 9713936cd47760c2ba0f259ec5b286ef7a898e84 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Sun, 24 Apr 2016 23:35:31 +0300 Subject: [PATCH] MT#18601 Consider cloudpbx feature configuration in tests Change-Id: I8c69abcf24779fb93af726294b56bb5c16b06ff6 --- t/api-rest/api-subscribers.t | 78 ++++++++++++++++++------------------ t/lib/Test/Collection.pm | 11 ++--- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/t/api-rest/api-subscribers.t b/t/api-rest/api-subscribers.t index 22eadef2f6..fc6645081d 100644 --- a/t/api-rest/api-subscribers.t +++ b/t/api-rest/api-subscribers.t @@ -144,44 +144,46 @@ my $remote_config = $test_machine->init_catalyst_config; } { #18601 - diag("18601"); - my $groups = $test_machine->check_create_correct( 3, sub{ - my $num = $_[1]->{i}; - $_[0]->{username} .= time().'_18601_'.$num ; - $_[0]->{webusername} .= time().'_'.$num; - $_[0]->{pbx_extension} .= '18601'.$num; - $_[0]->{primary_number}->{ac} .= $num; - $_[0]->{is_pbx_group} = 1; - $_[0]->{is_pbx_pilot} = ($pilot || $_[1]->{i} > 1)? 0 : 1; - delete $_[0]->{alias_numbers}; - } ); - my $members = $test_machine->check_create_correct( 3, sub{ - my $num = 3 + $_[1]->{i}; - $_[0]->{username} .= time().'_18601_'.$num ; - $_[0]->{webusername} .= time().'_'.$num; - $_[0]->{pbx_extension} .= '18601'.$num; - $_[0]->{primary_number}->{ac} .= $num; - $_[0]->{is_pbx_pilot} = 0; - $_[0]->{is_pbx_group} = 0; - delete $_[0]->{alias_numbers}; - }); - $members->[0]->{content}->{pbx_group_ids} = []; - diag("1. Check that member will return empty groups after put groups empty"); - my($member_put,$member_get) = $test_machine->check_put2get($members->[0]); - - $members->[0]->{content}->{pbx_group_ids} = [map { $groups->[$_]->{content}->{id} } (2,1)]; - diag("2. Check that member will return groups as they were specified"); - #($member_put,$member_get) = $test_machine->check_put2get($members->[0]); - - $groups->[1]->{content}->{pbx_groupmember_ids} = [map { $members->[$_]->{content}->{id} } (2,1,0)]; - diag("3. Check that group will return members as they were specified"); - #my($group_put,$group_get) = $test_machine->check_put2get($groups->[1]); - - $groups->[1]->{content}->{pbx_groupmember_ids} = []; - diag("4. Check that group will return empty members after put members empty"); - my($group_put,$group_get) = $test_machine->check_put2get($groups->[1]); - - $test_machine->clear_test_data_all();#fake data aren't registered in this test machine, so they will stay. + diag("18601: config->features->cloudpbx: ".$remote_config->{config}->{features}->{cloudpbx}.";\n"); + if($remote_config->{config}->{features}->{cloudpbx}){ + my $groups = $test_machine->check_create_correct( 3, sub{ + my $num = $_[1]->{i}; + $_[0]->{username} .= time().'_18601_'.$num ; + $_[0]->{webusername} .= time().'_'.$num; + $_[0]->{pbx_extension} .= '18601'.$num; + $_[0]->{primary_number}->{ac} .= $num; + $_[0]->{is_pbx_group} = 1; + $_[0]->{is_pbx_pilot} = ($pilot || $_[1]->{i} > 1)? 0 : 1; + delete $_[0]->{alias_numbers}; + } ); + my $members = $test_machine->check_create_correct( 3, sub{ + my $num = 3 + $_[1]->{i}; + $_[0]->{username} .= time().'_18601_'.$num ; + $_[0]->{webusername} .= time().'_'.$num; + $_[0]->{pbx_extension} .= '18601'.$num; + $_[0]->{primary_number}->{ac} .= $num; + $_[0]->{is_pbx_pilot} = 0; + $_[0]->{is_pbx_group} = 0; + delete $_[0]->{alias_numbers}; + }); + $members->[0]->{content}->{pbx_group_ids} = []; + diag("1. Check that member will return empty groups after put groups empty"); + my($member_put,$member_get) = $test_machine->check_put2get($members->[0]); + + $members->[0]->{content}->{pbx_group_ids} = [map { $groups->[$_]->{content}->{id} } (2,1)]; + diag("2. Check that member will return groups as they were specified"); + ($member_put,$member_get) = $test_machine->check_put2get($members->[0]); + + $groups->[1]->{content}->{pbx_groupmember_ids} = [map { $members->[$_]->{content}->{id} } (2,1,0)]; + diag("3. Check that group will return members as they were specified"); + my($group_put,$group_get) = $test_machine->check_put2get($groups->[1]); + + $groups->[1]->{content}->{pbx_groupmember_ids} = []; + diag("4. Check that group will return empty members after put members empty"); + my($group_put,$group_get) = $test_machine->check_put2get($groups->[1]); + + $test_machine->clear_test_data_all();#fake data aren't registered in this test machine, so they will stay. + } } $test_machine->clear_test_data_all();#fake data aren't registered in this test machine, so they will stay. done_testing; diff --git a/t/lib/Test/Collection.pm b/t/lib/Test/Collection.pm index 73959a6d7d..cfeefb6599 100644 --- a/t/lib/Test/Collection.pm +++ b/t/lib/Test/Collection.pm @@ -21,7 +21,7 @@ use Data::Dumper; has 'local_test' => ( is => 'rw', isa => 'Str', - default => $ENV{LOCAL_TEST} // '', + default => sub {$ENV{LOCAL_TEST} // ''}, ); has 'DEBUG' => ( @@ -53,9 +53,10 @@ has 'ua' => ( has 'base_uri' => ( is => 'ro', isa => 'Str', + lazy => 1, default => sub { - $_[0]->{local_test} - ? ( length($_[0]->{local_test})>1 ? $_[0]->{local_test} : 'https://127.0.0.1:4443' ) + $_[0]->local_test + ? ( length($_[0]->local_test)>1 ? $_[0]->local_test : 'https://127.0.0.1:1443' ) : $ENV{CATALYST_SERVER} || ('https://'.hostfqdn.':4443'); }, ); @@ -319,11 +320,11 @@ sub get_item_hal{ $uri //= $self->get_uri_collection($name)."?page=1&rows=1"; my($res,$list_collection,$req) = $self->check_item_get($self->normalize_uri($uri)); ($reshal,$location) = $self->get_hal_from_collection($list_collection,$name); - #if($reshal->{content}->{total_count}){ + if($reshal->{content}->{total_count}){ $resitem = { num => 1, content => $reshal, res => $res, req => $req, location => $location }; $self->DATA_LOADED->{$name} ||= []; push @{$self->DATA_LOADED->{$name}}, $resitem; - #} + } } return $resitem; }