From a4d7fa7a9144f7e853f54cf6ce015508d4db0a45 Mon Sep 17 00:00:00 2001 From: Flaviu Mates Date: Wed, 4 Sep 2019 22:51:52 +0300 Subject: [PATCH] TT#56467 - Fixes for Test Framework * change threads number to 2 as it temporarily fixes the 403 error for the first two test cases * add creating of contract in test case SubscriberRegistration because fetchig an existing one would fail Change-Id: I5f27c01f39f8611004618feebc9ed1b6a7ee8066 --- t/api-rest2/Subscribers.yaml | 71 +++++++++++++++++++++++++++++------- t/api-rest2/testrunner | 2 +- 2 files changed, 58 insertions(+), 15 deletions(-) diff --git a/t/api-rest2/Subscribers.yaml b/t/api-rest2/Subscribers.yaml index f7d9a65c4f..7e0eb72ff9 100644 --- a/t/api-rest2/Subscribers.yaml +++ b/t/api-rest2/Subscribers.yaml @@ -38,26 +38,68 @@ ok: '${domain}.id': defined -#get a customer for testing +#create a BillingProfile - - name: get a customer for testing + name: create a BillingProfile type: item - method: GET - path: '/api/customers/?page=1&rows=1&order_by=id&order_by_direction=desc' + method: POST + path: /api/billingprofiles/ + header: + Content-Type: application/json + Prefer: return=representation + content: + name: test profile ${unique_id} + handle: test_profile_handle${unique_id} + reseller_id: 1 + conditions: + is: + code: 201 retain: - customer: body + billing_profile_id: header.location + +#create a Customer Contact +- + name: create a Customer Contact + type: item + method: POST + path: /api/customercontacts/ + header: + Content-Type: application/json + content: + firstname: cust_contact_first + lastname: cust_contact_last + email: cust_contact@custcontact.invalid + reseller_id: 1 + conditions: + is: + code: 201 perl_code: !!perl/code | { my ($retained) = @_; - my $customer = $retained->{customer}->{'_embedded'}->{'ngcp:customers'}->[0]; - $retained->{customer} = $customer; - $retained->{customer_id} = $customer->{id}; - } - conditions: - is: - code: 200 - ok: - '${customer}.id': defined + $retained->{customer_type} = 'sipaccount'; + } + retain: + customer_contact_path: header.location + customer_contact_id: header.location + +#create Customer +- + name: include create Customer + type: include + file: CreateCustomer.yaml + perl_code: !!perl/code | + { + my ($retained) = @_; + + $retained->{customer_content} = { + status => 'active', + contact_id => $retained->{customer_contact_id}, + billing_profile_id => $retained->{billing_profile_id}, + type => 'sipaccount', + max_subscribers => undef, + external_id => undef + }; + } #get a subscriberprofile for testing - @@ -73,6 +115,7 @@ my $subscriberprofile = $retained->{subscriberprofile}->{'_embedded'}->{'ngcp:subscriberprofiles'}->[0]; $retained->{subscriberprofile} = $subscriberprofile; $retained->{subscriberprofile_id} = $subscriberprofile->{id}; + $retained->{customer_id} = $retained->{customer}->{id}; } conditions: is: diff --git a/t/api-rest2/testrunner b/t/api-rest2/testrunner index 31f6b96d10..2fa7649133 100755 --- a/t/api-rest2/testrunner +++ b/t/api-rest2/testrunner @@ -53,7 +53,7 @@ for ( @test_files ) { $tests_queue->end(); -for (1..4) { +for (1..2) { push @threads, threads->create( {'context' => 'scalar'}, \&worker, $tests_queue, 0 ); }