-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1085 from eciis/fix-duplicated-child-inst
Fix duplicated institution children
- Loading branch information
Showing
6 changed files
with
58 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,12 @@ def enqueue_task(self, handler_selector, params): | |
@patch('service_messages.send_message_notification') | ||
@patch('util.login_service.verify_token', return_value={'email': '[email protected]'}) | ||
def test_put(self, verify_token, mock_method): | ||
|
||
# Adding parent before the request to ensure overwrite the parent | ||
other_inst = mocks.create_institution() | ||
institution = self.inst_requested.key.get() | ||
institution.set_parent(other_inst.key) | ||
|
||
"""Test method post of InstitutionChildrenRequestHandler.""" | ||
request = self.testapp.put_json( | ||
"/api/requests/%s/institution_children" % self.request.key.urlsafe(), | ||
|
@@ -119,6 +125,11 @@ def test_put_user_not_admin(self, verify_token): | |
@patch('util.login_service.verify_token', return_value={'email': '[email protected]'}) | ||
def test_delete(self, verify_token, mock_method): | ||
"""Test method post of InstitutionChildrenRequestHandler.""" | ||
|
||
# Adding parent before request to ensure that parent link with the institution that which invited is removed. | ||
institution = self.inst_requested.key.get() | ||
institution.set_parent(self.inst_test.key) | ||
|
||
self.testapp.delete( | ||
"/api/requests/%s/institution_children" % self.request.key.urlsafe(), | ||
headers={"institution-authorization": self.inst_requested.key.urlsafe()} | ||
|
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 |
---|---|---|
|
@@ -71,21 +71,25 @@ def enqueue_task(self, handler_selector, params): | |
@patch('util.login_service.verify_token', return_value={'email': '[email protected]'}) | ||
def test_put(self, verify_token, send_notification): | ||
"""Test method put of InstitutionParentRequestHandler.""" | ||
|
||
# Adding child before the request to ensure that not add repeated child | ||
institution = self.inst_requested.key.get() | ||
institution.add_child(self.inst_test.key) | ||
|
||
request = self.testapp.put_json( | ||
"/api/requests/%s/institution_parent" % self.request.key.urlsafe(), | ||
headers={'institution-authorization': self.inst_requested.key.urlsafe()} | ||
) | ||
|
||
request = json.loads(request._app_iter[0]) | ||
|
||
institution = self.inst_requested.key.get() | ||
|
||
self.assertEqual( | ||
request['status'], | ||
'accepted', | ||
'Expected status from request must be accepted') | ||
self.assertEqual( | ||
institution.children_institutions[0], self.inst_test.key, | ||
institution.children_institutions, [self.inst_test.key], | ||
"The children institution of inst test must be update to inst_requested") | ||
|
||
message = { | ||
|
@@ -129,6 +133,11 @@ def test_put_user_not_admin(self, verify_token): | |
@patch('util.login_service.verify_token', return_value={'email': '[email protected]'}) | ||
def test_delete(self, verify_token, send_notification): | ||
"""Test method delete of InstitutionParentRequestHandler.""" | ||
|
||
# Adding child before the request to ensure that the existing link with the institution that which invited is removed. | ||
institution = self.inst_requested.key.get() | ||
institution.add_child(self.inst_test.key) | ||
|
||
self.testapp.delete( | ||
"/api/requests/%s/institution_parent" % self.request.key.urlsafe(), | ||
headers={'institution-authorization': self.inst_requested.key.urlsafe()} | ||
|
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