Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1806c85b
authored
Jun 01, 2021
by
Евгений
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавл расчеты баллов
1 parent
1d3edb98
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
app/Service/Requests/Direct/GetCampaigns.php
tests/Unit/LimitsTest.php
app/Service/Requests/Direct/GetCampaigns.php
View file @
1806c85
...
...
@@ -86,4 +86,12 @@ class GetCampaigns extends DirectRequest
}
$this
->
setParams
(
$params
);
}
function
getObjectsCount
(){
$params
=
$this
->
getParams
();
if
(
isset
(
$params
[
'SelectionCriteria'
][
'Ids'
])
&&
count
(
$params
[
'SelectionCriteria'
][
'Ids'
])
<
self
::
MAX_COUNT
){
return
count
(
$params
[
'SelectionCriteria'
][
'Ids'
]);
}
return
self
::
MAX_COUNT
;
}
}
tests/Unit/LimitsTest.php
View file @
1806c85
...
...
@@ -8,8 +8,10 @@ use App\Models\User;
use
App\Service\Contract\API
;
use
App\Service\HeaderLimits
;
use
App\Service\Limits
;
use
App\Service\Requests\DirectRequest
;
use
Illuminate\Database\Eloquent\ModelNotFoundException
;
use
Illuminate\Support\Facades\Date
;
use
Illuminate\Support\Facades\Queue
;
use
Tests\TestCase
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
...
...
@@ -119,7 +121,8 @@ class LimitsTest extends TestCase
public
function
testCountObjectsLimit
()
{
$request
=
\App\Service\Requests\APIRequest
::
getInstance
(
API
::
YANDEX
);
$request
=
\App\Service\Requests\APIRequest
::
getInstance
(
API
::
YANDEX
)
->
setToken
(
$this
->
token
);
$request
->
setService
(
'AdExtensions'
);
$request
->
setMethod
(
'add'
);
...
...
@@ -143,12 +146,32 @@ class LimitsTest extends TestCase
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$request
);
$this
->
assertEquals
(
$objects
,
4000
);
$request
->
setService
(
'Campaigns'
);
$request
->
setMethod
(
'update'
);
Queue
::
fake
();
$requestCmpgn
=
$request
->
getRequest
(
'Campaigns'
,
'get'
);
$this
->
token
->
limit
=
191
;
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$request
);
$this
->
assertEquals
(
$objects
,
60
);
$requestCmpgn
->
call
();
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
181
);
$this
->
token
->
limit
=
DirectRequest
::
MAX_COUNT
+
100
;
$requestCmpgn
->
call
();
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
DirectRequest
::
MAX_COUNT
);
$requestCmpgn
=
$request
->
getRequest
(
'Campaigns'
,
'update'
);
$this
->
token
->
limit
=
191
;
$requestCmpgn
->
call
([
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForExternalNeedUpdated
]);
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
0
);
$requestCmpgn
->
setParams
([
'Campaigns'
=>
[
1
,
2
,
3
]
]);
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
3
);
}
public
function
testDoRezervNoLimit
()
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment