-
Notifications
You must be signed in to change notification settings - Fork 185
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
Added Tests for Search Pipeline and Notifications Plugin #668
Merged
dblock
merged 6 commits into
opensearch-project:main
from
AbitraryYu:feature/search_pipeline_api
Apr 30, 2024
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
82cebac
Added Tests for Notification and Search Pipeline.ml
AbitraryYu debb7d1
Merge branch 'main' into feature/search_pipeline_api
AbitraryYu e8c413d
Add back the lines of comment in indices.py during resolving merge co…
AbitraryYu 2db146c
Fix notification plugin tests, from async def to def.
AbitraryYu 3240540
Fix test errors. Rename function names and rewrite assertion tests.
AbitraryYu 891c250
Fix formatting errors. Added typings to CONTENT.
AbitraryYu 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 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,35 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
# | ||
# Modifications Copyright OpenSearch Contributors. See | ||
# GitHub history for details. | ||
|
||
from test_opensearchpy.test_cases import OpenSearchTestCase | ||
|
||
|
||
class TestSearchPipeline(OpenSearchTestCase): | ||
def test_create_search_pipeline(self) -> None: | ||
body = { | ||
"request_processors": [ | ||
{ | ||
"filter_query": { | ||
"tag": "tag1", | ||
"description": "This processor returns only publicly visible documents", | ||
"query": {"term": {"visibility": "public"}}, | ||
} | ||
} | ||
], | ||
"response_processors": [ | ||
{"rename_field": {"field": "message", "target_field": "notification"}} | ||
], | ||
} | ||
|
||
self.client.search_pipeline.put("my_pipeline", body) | ||
self.assert_url_called("PUT", "/_search/pipeline/my_pipeline") | ||
|
||
def test_get_search_pipeline(self) -> None: | ||
self.client.search_pipeline.get("my_pipeline") | ||
self.assert_url_called("GET", "/_search/pipeline/my_pipeline") |
67 changes: 67 additions & 0 deletions
67
test_opensearchpy/test_server/test_plugins/test_notification.py
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,67 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
# | ||
# Modifications Copyright OpenSearch Contributors. See | ||
# GitHub history for details. | ||
|
||
|
||
from __future__ import unicode_literals | ||
|
||
from .. import OpenSearchTestCase | ||
|
||
|
||
class TestNotificationPlugin(OpenSearchTestCase): | ||
async def test_create_channel_notification(self) -> None: | ||
content = { | ||
"config_id": "sample-id", | ||
"name": "sample-name", | ||
"config": { | ||
"name": "Sample Slack Channel", | ||
"description": "This ialerting.create_destination(dummy_destination)s a Slack channel", | ||
"config_type": "slack", | ||
"is_enabled": True, | ||
"slack": {"url": "https://sample-slack-webhook"}, | ||
}, | ||
} | ||
response = self.client.plugins.notifications.create_config(content) | ||
|
||
self.assertNotIn("errors", response) | ||
self.assertIn("config_id", response) | ||
|
||
async def test_list_all_channel_configurations(self) -> None: | ||
response = self.client.plugins.notifications.list_features() | ||
|
||
self.assertNotIn("errors", response) | ||
self.assertIn("config_id", response) | ||
|
||
async def test_list_all_notification_configurations(self) -> None: | ||
response = self.client.plugins.notifications.get_config() | ||
|
||
self.assertNotIn("errors", response) | ||
self.assertIn("config_id", response) | ||
|
||
async def test_get_channel_configuration(self) -> None: | ||
response = self.client.plugins.notifications.get_config(config_id="sample-id") | ||
|
||
self.assertNotIn("errors", response) | ||
self.assertIn("config_id", response) | ||
|
||
async def test_update_channel_configuration(self) -> None: | ||
response = self.client.plugins.notifications.update_config( | ||
config_id="sample-id" | ||
) | ||
|
||
self.assertNotIn("errors", response) | ||
self.assertIn("config_id", response) | ||
|
||
async def test_delete_channel_configuration(self) -> None: | ||
# Try fetching the destination | ||
response = self.client.plugins.notifications.delete_config( | ||
config_id="sample-id" | ||
) | ||
|
||
self.assertNotIn("errors", response) | ||
self.assertIn("config_id", response) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.