-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclude deleted features from API responses. (#4619)
* Exclude deleted features from API responses. * Addressed review comment
- Loading branch information
Showing
6 changed files
with
59 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,15 +352,44 @@ def test_do_get__success(self, mock_get_approvers): | |
def test_do_get__empty_gates(self, mock_get_approvers): | ||
"""Handler cannnot find any gates.""" | ||
mock_get_approvers.return_value = ['[email protected]'] | ||
gateless_feature = core_models.FeatureEntry( | ||
name='gateless feature', summary='sum', category=1, | ||
owner_emails=['[email protected]']) | ||
gateless_feature.put() | ||
gateless_feature_id = gateless_feature.key.integer_id() | ||
|
||
with test_app.test_request_context(self.request_path): | ||
actual = self.handler.do_get(feature_id=gateless_feature_id) | ||
|
||
expected = { | ||
'gates': [], | ||
} | ||
self.assertEqual(actual, expected) | ||
|
||
def test_do_get__deleted(self): | ||
"""If a feature is deleted, don't return any gates.""" | ||
self.feature_1.deleted = True | ||
self.feature_1.put() | ||
|
||
with test_app.test_request_context(self.request_path): | ||
actual = self.handler.do_get(feature_id=999) | ||
actual = self.handler.do_get(feature_id=self.feature_id) | ||
|
||
expected = { | ||
'gates': [], | ||
} | ||
self.assertEqual(actual, expected) | ||
|
||
def test_do_get__include_deleted(self): | ||
"""If a feature is deleted, return gates if include_deleted=1.""" | ||
self.feature_1.deleted = True | ||
self.feature_1.put() | ||
|
||
with test_app.test_request_context( | ||
self.request_path + '?include_deleted=1'): | ||
actual = self.handler.do_get(feature_id=self.feature_id) | ||
|
||
self.assertEqual(1, len(actual['gates'])) | ||
|
||
|
||
class XfnGatesAPITest(testing_config.CustomTestCase): | ||
|
||
|
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