-
-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Splunk component filter support #25071
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
Changes from 4 commits
3e1b0a7
3514a8d
a8ce7f3
4381b3f
aa83aa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,12 @@ | |
| from homeassistant.const import STATE_ON, STATE_OFF, EVENT_STATE_CHANGED | ||
| from homeassistant.helpers import state as state_helper | ||
| import homeassistant.util.dt as dt_util | ||
| from homeassistant.core import State | ||
|
|
||
| from tests.common import get_test_home_assistant | ||
| from tests.common import ( | ||
| get_test_home_assistant, | ||
| mock_state_change_event | ||
| ) | ||
|
|
||
|
|
||
| class TestSplunk(unittest.TestCase): | ||
|
|
@@ -33,6 +37,14 @@ def test_setup_config_full(self): | |
| 'ssl': 'False', | ||
| 'verify_ssl': 'True', | ||
| 'name': 'hostname', | ||
| 'filter': { | ||
| 'exclude_domains': [ | ||
| 'fake' | ||
| ], | ||
| 'exclude_entities': [ | ||
| 'fake.entity' | ||
| ], | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -120,3 +132,54 @@ def test_event_listener(self, mock_requests): | |
| headers={'Authorization': 'Splunk secret'}, | ||
| timeout=10, verify=True) | ||
| self.mock_post.reset_mock() | ||
|
|
||
| def _setup_with_filter(self, mock_requests): | ||
|
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.
Contributor
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. Thanks. Missed that. I originally started trying to model my setup after another used for this component. I eventually deviated and went a whole other way (taking out use of mock_requests). Updated. |
||
| """Test the setup.""" | ||
| config = { | ||
| 'splunk': { | ||
| 'host': 'host', | ||
| 'token': 'secret', | ||
| 'port': 8088, | ||
| 'filter': { | ||
| 'exclude_domains': [ | ||
| 'excluded_domain' | ||
| ], | ||
| 'exclude_entities': [ | ||
| 'other_domain.excluded_entity' | ||
| ] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| setup_component(self.hass, splunk.DOMAIN, config) | ||
|
|
||
| @mock.patch.object(splunk, 'post_request') | ||
| def test_splunk_entityfilter(self, mock_requests): | ||
| """Test event listener.""" | ||
| self._setup_with_filter(mock_requests) | ||
|
|
||
| testdata = [ | ||
| { | ||
| 'entity_id': 'other_domain.other_entity', | ||
| 'filter_expected': False | ||
| }, | ||
| { | ||
| 'entity_id': 'other_domain.excluded_entity', | ||
| 'filter_expected': True | ||
| }, | ||
| { | ||
| 'entity_id': 'excluded_domain.other_entity', | ||
| 'filter_expected': True | ||
| } | ||
| ] | ||
|
|
||
| for test in testdata: | ||
| mock_state_change_event(self.hass, State(test['entity_id'], 'on')) | ||
| self.hass.block_till_done() | ||
|
|
||
| if test['filter_expected']: | ||
| assert not splunk.post_request.called | ||
| else: | ||
| assert splunk.post_request.called | ||
|
|
||
| splunk.post_request.reset_mock() | ||
Uh oh!
There was an error while loading. Please reload this page.