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 ce22f089
authored
Jun 08, 2021
by
Евгений
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Поправил для тестов
1 parent
a38145d4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
9 deletions
app/Console/Commands/CampaignsSuspend.php
app/Service/API/YandexDirect.php
app/Service/Requests/DirectRequest.php
tests/Unit/CallLimitedApiTest.php
tests/Unit/LimitsTest.php
app/Console/Commands/CampaignsSuspend.php
View file @
ce22f08
...
@@ -67,8 +67,6 @@ class CampaignsSuspend extends Command
...
@@ -67,8 +67,6 @@ class CampaignsSuspend extends Command
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
dd
(
$token
->
dictionaryCampaignsNotEnabledForExternalNotDisabled
);
$factory
->
getRequest
(
'Campaigns'
,
'suspend'
)
$factory
->
getRequest
(
'Campaigns'
,
'suspend'
)
->
call
([
->
call
([
'ids'
=>
$token
->
dictionaryCampaignsNotEnabledForExternalNotDisabled
->
pluck
(
'external_id'
)
->
all
(),
'ids'
=>
$token
->
dictionaryCampaignsNotEnabledForExternalNotDisabled
->
pluck
(
'external_id'
)
->
all
(),
...
...
app/Service/API/YandexDirect.php
View file @
ce22f08
...
@@ -42,6 +42,7 @@ class YandexDirect extends API{
...
@@ -42,6 +42,7 @@ class YandexDirect extends API{
public
function
execute
()
:
Response
public
function
execute
()
:
Response
{
{
print_r
(
$this
->
request
->
getBody
());
return
Http
::
withBody
(
$this
->
request
->
getBody
(),
'none'
)
return
Http
::
withBody
(
$this
->
request
->
getBody
(),
'none'
)
->
withHeaders
(
$this
->
request
->
getHeaders
())
->
withHeaders
(
$this
->
request
->
getHeaders
())
->
withToken
(
$this
->
request
->
getToken
()
->
token
)
->
withToken
(
$this
->
request
->
getToken
()
->
token
)
...
...
app/Service/Requests/DirectRequest.php
View file @
ce22f08
...
@@ -11,6 +11,7 @@ namespace App\Service\Requests;
...
@@ -11,6 +11,7 @@ namespace App\Service\Requests;
class
DirectRequest
extends
APIRequest
class
DirectRequest
extends
APIRequest
{
{
CONST
MAX_COUNT
=
10000
;
protected
$max_count
=
-
1
;
protected
$max_count
=
-
1
;
private
$url
;
private
$url
;
...
...
tests/Unit/CallLimitedApiTest.php
View file @
ce22f08
...
@@ -56,12 +56,6 @@ class CallLimitedApiTest extends TestCase
...
@@ -56,12 +56,6 @@ class CallLimitedApiTest extends TestCase
dispatch
(
$process
)
->
onQueue
(
'limits'
);
dispatch
(
$process
)
->
onQueue
(
'limits'
);
Queue
::
assertPushed
(
ProcessCallLimitedAPI
::
class
,
2
);
Queue
::
assertPushed
(
ProcessCallLimitedAPI
::
class
,
2
);
$this
->
token
->
limit
=
14
;
$this
->
request
->
setService
(
'AdGroups'
);
$this
->
request
->
setMethod
(
'get'
);
$process
->
handle
();
Queue
::
assertPushed
(
ProcessCallLimitedAPI
::
class
,
3
);
$this
->
token
->
limit
=
15
;
$this
->
token
->
limit
=
15
;
$this
->
request
->
setService
(
'AdGroups'
);
$this
->
request
->
setService
(
'AdGroups'
);
$this
->
request
->
setMethod
(
'get'
);
$this
->
request
->
setMethod
(
'get'
);
...
...
tests/Unit/LimitsTest.php
View file @
ce22f08
...
@@ -161,7 +161,12 @@ class LimitsTest extends TestCase
...
@@ -161,7 +161,12 @@ class LimitsTest extends TestCase
$this
->
token
->
limit
=
191
;
$this
->
token
->
limit
=
191
;
$requestCmpgn
->
call
();
$requestCmpgn
->
call
();
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
-
1
);
$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'
);
$requestCmpgn
=
$request
->
getRequest
(
'Campaigns'
,
'update'
);
$this
->
token
->
limit
=
191
;
$this
->
token
->
limit
=
191
;
...
@@ -184,6 +189,18 @@ class LimitsTest extends TestCase
...
@@ -184,6 +189,18 @@ class LimitsTest extends TestCase
$request
->
setService
(
'AdExtensions'
);
$request
->
setService
(
'AdExtensions'
);
$request
->
setMethod
(
'add'
);
$request
->
setMethod
(
'add'
);
$rezerv
=
new
\App\Models\Limits
();
$rezerv
->
token
=
$this
->
token
->
id
;
$rezerv
->
service
=
'dsd'
;
$rezerv
->
method
=
'asdas'
;
$rezerv
->
spent
=
1
;
$rezerv
->
day
=
0
;
$rezerv
->
current
=
$this
->
token
->
limit
;
$rezerv
->
reserved
=
1
;
$rezerv
->
save
();
$this
->
token
->
refresh
();
//т.к. для первого вызова не будет происходить проверки баллов
$this
->
expectException
(
\Exception
::
class
);
$this
->
expectException
(
\Exception
::
class
);
$this
->
limitService
->
doRezerv
(
$request
,
$this
->
token
->
limit
);
$this
->
limitService
->
doRezerv
(
$request
,
$this
->
token
->
limit
);
}
}
...
...
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