This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
d92bf03
commit f03bccc
Showing
7 changed files
with
98 additions
and
8 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
-r ./requirements.txt | ||
autopep8 ~= 1.3 | ||
coverage ~= 4.4.1 | ||
coverage ~= 4.4.2 | ||
coveralls ~= 1.2.0 | ||
flake8 ~= 3.3.0 | ||
nose2 ~= 0.6.5 | ||
flake8 ~= 3.5.0 | ||
nose2 ~= 0.7.2 |
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
certifi==2017.11.5 | ||
chardet==3.0.4 | ||
click==6.7 | ||
Flask==0.12.2 | ||
idna==2.6 | ||
itsdangerous==0.24 | ||
Jinja2==2.10 | ||
MarkupSafe==1.0 | ||
requests==2.18.4 | ||
urllib3==1.22 | ||
Werkzeug==0.12.2 |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
flask ~= 0.12.2 | ||
flask ~= 0.12.2 | ||
requests ~= 2.18.4 |
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
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,42 @@ | ||
from unittest import TestCase | ||
|
||
from tk.flask.app import App | ||
|
||
|
||
def data_provider(data_provider): | ||
def decorator(test_method): | ||
def multiplier(self, *test_method_args, **test_method_kwargs): | ||
""" | ||
The replacement (decorated) test method. | ||
:param self: | ||
:param args: | ||
:return: | ||
""" | ||
for fixture_name, test_method_fixture_args in data_provider().items(): | ||
try: | ||
test_method(self, *test_method_args, | ||
*test_method_fixture_args, | ||
**test_method_kwargs) | ||
except AssertionError: | ||
raise AssertionError( | ||
'Assertion failed with data set "%s"' % str(fixture_name)) | ||
except Exception: | ||
raise AssertionError( | ||
'Unexpected error with data set "%s"' % str( | ||
fixture_name)) | ||
|
||
return multiplier | ||
|
||
return decorator | ||
|
||
|
||
class IntegrationTestCase(TestCase): | ||
def setUp(self): | ||
self._flask_app = App() | ||
self._flask_app.config.update(SERVER_NAME='example.com') | ||
self._flask_app_context = self._flask_app.app_context() | ||
self._flask_app_context.push() | ||
self._flask_app_client = self._flask_app.test_client() | ||
|
||
def tearDown(self): | ||
self._flask_app_context.pop() |
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,31 @@ | ||
from tk.tests import IntegrationTestCase, data_provider | ||
|
||
|
||
def provide_disallowed_submit_methods(): | ||
return { | ||
'GET': ('GET',), | ||
'PUT': ('PUT',), | ||
'PATCH': ('PATCH',), | ||
'DELETE': ('DELETE',), | ||
} | ||
|
||
|
||
def provide_disallowed_retrieve_methods(): | ||
return { | ||
'POST': ('POST',), | ||
'PUT': ('PUT',), | ||
'PATCH': ('PATCH',), | ||
'DELETE': ('DELETE',), | ||
} | ||
|
||
|
||
class StaticEndpointRepositoryTest(IntegrationTestCase): | ||
@data_provider(provide_disallowed_submit_methods) | ||
def testSubmitWithDisallowedMethodShould405(self, method): | ||
response = self._flask_app_client.open('/submit', method=method) | ||
self.assertEquals(405, response.status_code) | ||
|
||
@data_provider(provide_disallowed_retrieve_methods) | ||
def testRetrieveWithDisallowedMethodShould405(self, method): | ||
response = self._flask_app_client.open('/retrieve/foo', method=method) | ||
self.assertEquals(405, response.status_code) |