Skip to content

Commit

Permalink
[tests] adding unit test for log count
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandeivert committed Jan 3, 2018
1 parent e12a5ba commit 59fe3ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def test_check_exists_get_id_fail(self, get_mock):

@patch('requests.get')
def test_check_exists_no_get_id(self, get_mock):
"""Check Exists No Get Id - PagerDutyIncidentOutput"""
"""PagerDutyIncidentOutput - Check Exists No Get Id"""
# /check
get_mock.return_value.status_code = 200
json_check = {'check': [{'id': 'checked_id'}]}
Expand Down
13 changes: 9 additions & 4 deletions tests/unit/stream_alert_rule_processor/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
# pylint: disable=protected-access
# pylint: disable=protected-access,attribute-defined-outside-init
import base64
import json
import logging
Expand Down Expand Up @@ -45,9 +45,6 @@
class TestStreamAlert(object):
"""Test class for StreamAlert class"""

def __init__(self):
self.__sa_handler = None

@patch('stream_alert.rule_processor.handler.load_config',
lambda: load_config('tests/unit/conf/'))
def setup(self):
Expand Down Expand Up @@ -131,6 +128,14 @@ def test_run_with_alert(self, extract_mock, rules_mock):

assert_true(passed)

@patch('stream_alert.rule_processor.handler.StreamClassifier.extract_service_and_entity')
def test_run_alert_count(self, extract_mock):
"""StreamAlert Class - Run, Check Count With 4 Logs"""
count = 4
extract_mock.return_value = ('kinesis', 'unit_test_default_stream')
self.__sa_handler.run(get_valid_event(count))
assert_equal(self.__sa_handler._processed_record_count, count)

@patch('logging.Logger.debug')
@patch('stream_alert.rule_processor.handler.StreamClassifier.extract_service_and_entity')
def test_run_no_alerts(self, extract_mock, log_mock):
Expand Down

0 comments on commit 59fe3ff

Please sign in to comment.