-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'GoogleChrome:main' into main
- Loading branch information
Showing
64 changed files
with
1,254 additions
and
595 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 |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
from api import feature_latency_api | ||
from internals.core_enums import * | ||
from internals.core_models import FeatureEntry, Stage, MilestoneSet | ||
from internals import user_models | ||
|
||
|
||
test_app = flask.Flask(__name__) | ||
|
@@ -45,6 +46,10 @@ def make_feature(name, created_tuple, status, shipped): | |
class FeatureLatencyAPITest(testing_config.CustomTestCase): | ||
|
||
def setUp(self): | ||
self.app_admin = user_models.AppUser(email='[email protected]') | ||
self.app_admin.is_admin = True | ||
self.app_admin.put() | ||
|
||
self.handler = feature_latency_api.FeatureLatencyAPI() | ||
self.request_path = '/api/v0/feature-latency' | ||
|
||
|
@@ -64,6 +69,8 @@ def setUp(self): | |
'launched after end', (2023, 9, 29), ENABLED_BY_DEFAULT, 125) | ||
|
||
def tearDown(self): | ||
testing_config.sign_out() | ||
self.app_admin.key.delete() | ||
kinds: list[ndb.Model] = [FeatureEntry, Stage] | ||
for kind in kinds: | ||
for entity in kind.query(): | ||
|
@@ -85,8 +92,23 @@ def test_get_date_range__specified(self): | |
datetime(2023, 12, 24)), | ||
actual) | ||
|
||
def test_do_get__anon(self): | ||
"""Only users who can create features can view reports.""" | ||
testing_config.sign_out() | ||
with test_app.test_request_context(self.request_path): | ||
with self.assertRaises(werkzeug.exceptions.Forbidden): | ||
self.handler.do_get() | ||
|
||
def test_do_get__rando(self): | ||
"""Only users who can create features can view reports.""" | ||
testing_config.sign_in('[email protected]', 1232345) | ||
with test_app.test_request_context(self.request_path): | ||
with self.assertRaises(werkzeug.exceptions.Forbidden): | ||
self.handler.do_get() | ||
|
||
def test_do_get__normal(self): | ||
"""It finds some feature launches to include and excludes others.""" | ||
testing_config.sign_in('[email protected]', 123567890) | ||
path = self.request_path + '?startAt=2023-01-01&endAt=2024-01-01' | ||
with test_app.test_request_context(path): | ||
actual = self.handler.do_get() | ||
|
@@ -103,6 +125,7 @@ def test_do_get__normal(self): | |
|
||
def test_do_get__zero_results(self): | ||
"""There were no test launches in this range.""" | ||
testing_config.sign_in('[email protected]', 123567890) | ||
path = self.request_path + '?startAt=2020-01-01&endAt=2020-03-01' | ||
with test_app.test_request_context(path): | ||
actual = self.handler.do_get() | ||
|
Oops, something went wrong.