Skip to content

Commit

Permalink
[test] adding test for converting nested type
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandeivert committed Nov 8, 2017
1 parent ee843dd commit 147b1ad
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/unit/stream_alert_rule_processor/test_classifier.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,too-many-public-methods
import json

from mock import call, patch
Expand Down Expand Up @@ -84,6 +84,19 @@ def test_convert_type_invalid_int(self, log_mock):
'key_01',
'NotInt')

@patch('logging.Logger.error')
def test_convert_type_invalid_nested(self, log_mock):
"""StreamClassifier - Convert Type, Invalid Nested Type"""
payload = {'key_01': '100', 'streamalert:envelope_keys': {'host': 'NotInt'}}
schema = {'key_01': 'integer', 'streamalert:envelope_keys': {'host': 'integer'}}

assert_false(self.classifier._convert_type(payload, schema))

log_mock.assert_called_with(
'Invalid schema. Value for key [%s] is not an int: %s',
'host',
'NotInt')

def test_convert_type_valid_float(self):
"""StreamClassifier - Convert Type, Valid Float"""
payload = {'key_01': '12.1'}
Expand Down

0 comments on commit 147b1ad

Please sign in to comment.