-
Notifications
You must be signed in to change notification settings - Fork 18k
[dashboard] New, add statsd incr to the API #9519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dpgaspar
merged 12 commits into
apache:master
from
preset-io:feature/api-statsd-dashboards
Apr 16, 2020
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7413150
[dashboard] New, add statsd incr to the API
dpgaspar d88c73c
[dashboard] improve metrics and DRY
dpgaspar c899d8b
Merge remote-tracking branch 'upstream/master' into feature/api-stats…
dpgaspar e5a9740
Add tests
dpgaspar 5e27908
[dashboards] DRYing
dpgaspar f73547e
[dashboards] lint
dpgaspar 6e79be1
wakey wakey GitHub Actions
dpgaspar 735a3a7
[dashboards] lint
dpgaspar 339f098
Merge remote-tracking branch 'upstream/master' into feature/api-stats…
dpgaspar ba1c59e
[tests] Fix docs
dpgaspar f2170ac
[tests] Fix docs
dpgaspar 18f1eb2
[tests] Fix docs
dpgaspar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -85,7 +85,7 @@ def test_get_dashboard(self): | |
| dashboard = self.insert_dashboard("title", "slug1", [admin.id]) | ||
| self.login(username="admin") | ||
| uri = f"api/v1/dashboard/{dashboard.id}" | ||
| rv = self.client.get(uri) | ||
| rv = self.get_assert_metric(uri, "get") | ||
| self.assertEqual(rv.status_code, 200) | ||
| expected_result = { | ||
| "changed_by": None, | ||
|
|
@@ -120,14 +120,23 @@ def test_get_dashboard(self): | |
| db.session.delete(dashboard) | ||
| db.session.commit() | ||
|
|
||
| def test_info_dashboard(self): | ||
| """ | ||
| Dashboard API: Test info | ||
| """ | ||
|
Comment on lines
+125
to
+127
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still one to go
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not one, a bunch of them :) fixed all docs string for dashboards |
||
| self.login(username="admin") | ||
| uri = f"api/v1/dashboard/_info" | ||
| rv = self.get_assert_metric(uri, "info") | ||
| self.assertEqual(rv.status_code, 200) | ||
|
|
||
| def test_get_dashboard_not_found(self): | ||
| """ | ||
| Dashboard API: Test get dashboard not found | ||
| """ | ||
| max_id = db.session.query(func.max(Dashboard.id)).scalar() | ||
| self.login(username="admin") | ||
| uri = f"api/v1/dashboard/{max_id + 1}" | ||
| rv = self.client.get(uri) | ||
| rv = self.get_assert_metric(uri, "get") | ||
| self.assertEqual(rv.status_code, 404) | ||
|
|
||
| def test_get_dashboard_no_data_access(self): | ||
|
|
@@ -159,7 +168,8 @@ def test_get_dashboards_filter(self): | |
| "filters": [{"col": "dashboard_title", "opr": "sw", "value": "ti"}] | ||
| } | ||
| uri = f"api/v1/dashboard/?q={prison.dumps(arguments)}" | ||
| rv = self.client.get(uri) | ||
|
|
||
| rv = self.get_assert_metric(uri, "get_list") | ||
| self.assertEqual(rv.status_code, 200) | ||
| data = json.loads(rv.data.decode("utf-8")) | ||
| self.assertEqual(data["count"], 1) | ||
|
|
@@ -258,7 +268,7 @@ def test_delete_dashboard(self): | |
| dashboard_id = self.insert_dashboard("title", "slug1", [admin_id]).id | ||
| self.login(username="admin") | ||
| uri = f"api/v1/dashboard/{dashboard_id}" | ||
| rv = self.client.delete(uri) | ||
| rv = self.delete_assert_metric(uri, "delete") | ||
| self.assertEqual(rv.status_code, 200) | ||
| model = db.session.query(Dashboard).get(dashboard_id) | ||
| self.assertEqual(model, None) | ||
|
|
@@ -281,7 +291,7 @@ def test_delete_bulk_dashboards(self): | |
| self.login(username="admin") | ||
| argument = dashboard_ids | ||
| uri = f"api/v1/dashboard/?q={prison.dumps(argument)}" | ||
| rv = self.client.delete(uri) | ||
| rv = self.delete_assert_metric(uri, "bulk_delete") | ||
| self.assertEqual(rv.status_code, 200) | ||
| response = json.loads(rv.data.decode("utf-8")) | ||
| expected_response = {"message": f"Deleted {dashboard_count} dashboards"} | ||
|
|
@@ -468,7 +478,7 @@ def test_create_dashboard(self): | |
| } | ||
| self.login(username="admin") | ||
| uri = "api/v1/dashboard/" | ||
| rv = self.client.post(uri, json=dashboard_data) | ||
| rv = self.post_assert_metric(uri, dashboard_data, "post") | ||
| self.assertEqual(rv.status_code, 201) | ||
| data = json.loads(rv.data.decode("utf-8")) | ||
| model = db.session.query(Dashboard).get(data.get("id")) | ||
|
|
@@ -520,7 +530,7 @@ def test_create_dashboard_validate_title(self): | |
| dashboard_data = {"dashboard_title": "a" * 600} | ||
| self.login(username="admin") | ||
| uri = "api/v1/dashboard/" | ||
| rv = self.client.post(uri, json=dashboard_data) | ||
| rv = self.post_assert_metric(uri, dashboard_data, "post") | ||
| self.assertEqual(rv.status_code, 400) | ||
| response = json.loads(rv.data.decode("utf-8")) | ||
| expected_response = { | ||
|
|
@@ -603,7 +613,7 @@ def test_update_dashboard(self): | |
| dashboard_id = self.insert_dashboard("title1", "slug1", [admin.id]).id | ||
| self.login(username="admin") | ||
| uri = f"api/v1/dashboard/{dashboard_id}" | ||
| rv = self.client.put(uri, json=self.dashboard_data) | ||
| rv = self.put_assert_metric(uri, self.dashboard_data, "put") | ||
| self.assertEqual(rv.status_code, 200) | ||
| model = db.session.query(Dashboard).get(dashboard_id) | ||
| self.assertEqual(model.dashboard_title, self.dashboard_data["dashboard_title"]) | ||
|
|
@@ -801,7 +811,7 @@ def test_update_dashboard_not_owned(self): | |
| self.login(username="alpha2", password="password") | ||
| dashboard_data = {"dashboard_title": "title1_changed", "slug": "slug1 changed"} | ||
| uri = f"api/v1/dashboard/{dashboard.id}" | ||
| rv = self.client.put(uri, json=dashboard_data) | ||
| rv = self.put_assert_metric(uri, dashboard_data, "put") | ||
| self.assertEqual(rv.status_code, 403) | ||
| db.session.delete(dashboard) | ||
| db.session.delete(user_alpha1) | ||
|
|
@@ -815,8 +825,7 @@ def test_export(self): | |
| self.login(username="admin") | ||
| argument = [1, 2] | ||
| uri = f"api/v1/dashboard/export/?q={prison.dumps(argument)}" | ||
|
|
||
| rv = self.client.get(uri) | ||
| rv = self.get_assert_metric(uri, "export") | ||
| self.assertEqual(rv.status_code, 200) | ||
| self.assertEqual( | ||
| rv.headers["Content-Disposition"], | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.