-
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
farzeneka
committed
Jul 1, 2019
1 parent
873d871
commit cd11084
Showing
6 changed files
with
108 additions
and
11 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
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
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,5 +1,5 @@ | ||
from auditor.context import Context as AuditLogContext | ||
from bddrest import status, response, when | ||
from bddrest import status, response, when, given | ||
from nanohttp.contexts import Context | ||
from nanohttp import context | ||
|
||
|
@@ -64,23 +64,59 @@ def mockup(cls): | |
session.commit() | ||
|
||
def test_append(self): | ||
session = self.create_session() | ||
self.login('[email protected]') | ||
|
||
with oauth_mockup_server(), self.given( | ||
'Appending a batch', | ||
f'/apiv1/batches/id: {self.batch1.id}', | ||
'APPEND', | ||
form=dict( | ||
json=dict( | ||
issueIds=self.issue1.id | ||
) | ||
): | ||
assert status == 200 | ||
assert response.json['id'] is not None | ||
assert response.json['title'] == self.batch1.title | ||
assert response.json['projectId'] == self.project1.id | ||
# assert self.issue1.id in response.json['issueIds'] | ||
# assert len(response.json['issueIds']) == 1 | ||
assert self.issue1.id in response.json['issueIds'] | ||
assert len(response.json['issueIds']) == 1 | ||
|
||
when( | ||
'Trying to pass without issue id', | ||
json=given - 'issueIds' | ||
) | ||
assert status == '723 Issue Id Not In Form' | ||
|
||
when( | ||
'Trying to pass with invalid issue id type', | ||
json=given | dict(issueIds='a') | ||
) | ||
assert status == '722 Invalid Issue Id Type' | ||
|
||
when( | ||
'Trying to pass with none issue id', | ||
json=given | dict(issueIds=None) | ||
) | ||
assert status == '775 Issue Id Is Null' | ||
|
||
when( | ||
'Issue is not found', | ||
json=given | dict(issueIds=0) | ||
) | ||
assert status == '605 Issue Not Found: 0' | ||
|
||
when( | ||
'Inended batch with integer type not found', | ||
url_parameters=dict(id=0) | ||
) | ||
assert status == 404 | ||
when( | ||
'Inended batch with string type not found', | ||
url_parameters=dict(id='Alaphabet') | ||
) | ||
assert status == 404 | ||
|
||
when('Request is not authorized', authorization=None) | ||
assert status == 401 | ||
|
||
# TODO: test when issueId missing | ||
# TODO: test when invalid issueId type | ||
# TODO: test when isuueId is none |
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,39 @@ | ||
from bddrest.authoring import status, response | ||
|
||
from dolphin.tests.helpers import LocalApplicationTestCase | ||
|
||
|
||
class TestBatch(LocalApplicationTestCase): | ||
|
||
def test_metadata(self): | ||
with self.given( | ||
'Test metadata verb', | ||
'/apiv1/batches', | ||
'METADATA' | ||
): | ||
assert status == 200 | ||
|
||
fields = response.json['fields'] | ||
|
||
assert fields['id']['primaryKey'] is not None | ||
assert fields['id']['readonly'] is not None | ||
assert fields['id']['notNone'] is not None | ||
assert fields['id']['required'] is not None | ||
assert fields['id']['label'] is not None | ||
assert fields['id']['minimum'] is not None | ||
assert fields['id']['example'] is not None | ||
assert fields['id']['protected'] is not None | ||
|
||
assert fields['title']['minLength'] is not None | ||
assert fields['title']['label'] is not None | ||
assert fields['title']['watermark'] is not None | ||
assert fields['title']['example'] is not None | ||
assert fields['title']['notNone'] is not None | ||
assert fields['title']['required'] is not None | ||
assert fields['title']['protected'] is not None | ||
assert fields['title']['type'] is not None | ||
|
||
assert fields['projectId']['key'] is not None | ||
assert fields['projectId']['notNone'] is not None | ||
assert fields['projectId']['readonly'] is not None | ||
|