-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .cron import CronTestCase, CronTestClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from rest_framework.test import APIClient, APITestCase | ||
|
||
|
||
class CronTestClient(APIClient): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs, HTTP_X_APPENGINE_CRON="true") | ||
|
||
def generic( | ||
self, | ||
method, | ||
path, | ||
data="", | ||
content_type="application/octet-stream", | ||
secure=False, | ||
**extra, | ||
): | ||
wsgi_response = super().generic( | ||
method, path, data, content_type, secure, **extra | ||
) | ||
assert ( | ||
200 <= wsgi_response.status_code < 300 | ||
), f"Response has error status code: {wsgi_response.status_code}" | ||
|
||
return wsgi_response | ||
|
||
|
||
class CronTestCase(APITestCase): | ||
client_class = CronTestClient |