コード例 #1
0
ファイル: test_spec.py プロジェクト: rackerlabs/otter
 def test_message_is_changed(self):
     """
     Event's message is changed with msg type if found.
     otter_msg_type is added
     """
     e = {'message': ('delete-server',), 'a': 'b'}
     self.assertEqual(
         get_validated_event(e),
         [{'message': ('Deleting {server_id} server',),
           'a': 'b', 'otter_msg_type': 'delete-server'}])
コード例 #2
0
ファイル: test_spec.py プロジェクト: stanzikratel/otter
 def test_error_why_is_changed(self):
     """
     Error-based event's why is changed if found in msg_types.
     otter_msg_type is added
     """
     e = {"isError": True, "why": "delete-server", "a": "b"}
     self.assertEqual(
         get_validated_event(e),
         [{"why": "Deleting {server_id} server", "isError": True, "a": "b", "otter_msg_type": "delete-server"}],
     )
コード例 #3
0
ファイル: test_spec.py プロジェクト: rackerlabs/otter
 def test_error_no_why_but_message(self):
     """
     When error-based event does not have "why", then its message is tried
     """
     e = {'isError': True, 'a': 'b', "message": ('delete-server',)}
     self.assertEqual(
         get_validated_event(e),
         [{'message': ('Deleting {server_id} server',), 'isError': True,
           'why': 'Deleting {server_id} server',
           'a': 'b', 'otter_msg_type': 'delete-server'}])
コード例 #4
0
ファイル: test_spec.py プロジェクト: stanzikratel/otter
 def test_message_is_changed(self):
     """
     Event's message is changed with msg type if found.
     otter_msg_type is added
     """
     e = {"message": ("delete-server",), "a": "b"}
     self.assertEqual(
         get_validated_event(e),
         [{"message": ("Deleting {server_id} server",), "a": "b", "otter_msg_type": "delete-server"}],
     )
コード例 #5
0
ファイル: test_spec.py プロジェクト: stanzikratel/otter
 def test_callable_spec(self):
     """
     Spec values can be callable, in which case they will be called with the
     event dict, and their return value will be used as the new `message`.
     """
     e = {"message": ("foo-bar",), "ab": "cd"}
     self.assertEqual(
         get_validated_event(e, specs={"foo-bar": lambda e: [(e, e["ab"])]}),
         [{"message": ("cd",), "otter_msg_type": "foo-bar", "ab": "cd"}],
     )
コード例 #6
0
ファイル: test_spec.py プロジェクト: stanzikratel/otter
 def test_callable_spec_error(self):
     """
     Spec values will be called for errors as well, and their return will be
     used as the new value for `why`.
     """
     e = {"isError": True, "why": "foo-bar", "ab": "cd"}
     self.assertEqual(
         get_validated_event(e, specs={"foo-bar": lambda e: [(e, e["ab"])]}),
         [{"why": "cd", "isError": True, "otter_msg_type": "foo-bar", "ab": "cd"}],
     )
コード例 #7
0
ファイル: test_spec.py プロジェクト: rackerlabs/otter
 def test_error_why_is_changed(self):
     """
     Error-based event's why is changed if found in msg_types.
     otter_msg_type is added
     """
     e = {'isError': True, 'why': 'delete-server', 'a': 'b'}
     self.assertEqual(
         get_validated_event(e),
         [{'why': 'Deleting {server_id} server',
           'isError': True, 'a': 'b',
           'otter_msg_type': 'delete-server'}])
コード例 #8
0
ファイル: test_spec.py プロジェクト: manishtomar/otter
 def test_message_is_changed(self):
     """
     Event's message is changed with msg type if found.
     otter_msg_type is added
     """
     e = {'message': ('delete-server', ), 'a': 'b'}
     self.assertEqual(get_validated_event(e),
                      [{
                          'message': ('Deleting {server_id} server', ),
                          'a': 'b',
                          'otter_msg_type': 'delete-server'
                      }])
コード例 #9
0
ファイル: test_spec.py プロジェクト: rackerlabs/otter
 def test_callable_spec(self):
     """
     Spec values can be callable, in which case they will be called with the
     event dict, and their return value will be used as the new `message`.
     """
     e = {"message": ('foo-bar',), 'ab': 'cd'}
     self.assertEqual(
         get_validated_event(e,
                             specs={'foo-bar': lambda e: [(e, e['ab'])]}),
         [{'message': ('cd',),
           'otter_msg_type': 'foo-bar',
           'ab': 'cd'}])
コード例 #10
0
ファイル: test_spec.py プロジェクト: manishtomar/otter
 def test_error_why_is_changed(self):
     """
     Error-based event's why is changed if found in msg_types.
     otter_msg_type is added
     """
     e = {'isError': True, 'why': 'delete-server', 'a': 'b'}
     self.assertEqual(get_validated_event(e),
                      [{
                          'why': 'Deleting {server_id} server',
                          'isError': True,
                          'a': 'b',
                          'otter_msg_type': 'delete-server'
                      }])
コード例 #11
0
ファイル: test_spec.py プロジェクト: manishtomar/otter
 def test_error_no_why_but_message(self):
     """
     When error-based event does not have "why", then its message is tried
     """
     e = {'isError': True, 'a': 'b', "message": ('delete-server', )}
     self.assertEqual(get_validated_event(e),
                      [{
                          'message': ('Deleting {server_id} server', ),
                          'isError': True,
                          'why': 'Deleting {server_id} server',
                          'a': 'b',
                          'otter_msg_type': 'delete-server'
                      }])
コード例 #12
0
ファイル: test_spec.py プロジェクト: rackerlabs/otter
 def test_callable_spec_error(self):
     """
     Spec values will be called for errors as well, and their return will be
     used as the new value for `why`.
     """
     e = {'isError': True, 'why': 'foo-bar', 'ab': 'cd'}
     self.assertEqual(
         get_validated_event(e,
                             specs={'foo-bar': lambda e: [(e, e['ab'])]}),
         [{'why': 'cd',
           'isError': True,
           'otter_msg_type': 'foo-bar',
           'ab': 'cd'}])
コード例 #13
0
ファイル: test_spec.py プロジェクト: manishtomar/otter
 def test_callable_spec(self):
     """
     Spec values can be callable, in which case they will be called with the
     event dict, and their return value will be used as the new `message`.
     """
     e = {"message": ('foo-bar', ), 'ab': 'cd'}
     self.assertEqual(
         get_validated_event(e, specs={'foo-bar':
                                       lambda e: [(e, e['ab'])]}),
         [{
             'message': ('cd', ),
             'otter_msg_type': 'foo-bar',
             'ab': 'cd'
         }])
コード例 #14
0
ファイル: test_spec.py プロジェクト: stanzikratel/otter
 def test_callable_spec_split_events(self):
     """
     Event dictionaries returned will have a field tracking how many events
     the original event was split into.
     """
     e = {"isError": True, "why": "foo-bar", "ab": "cd"}
     specs = {"foo-bar": lambda e: [(e, e["ab"]), (e.copy(), "another")]}
     self.assertEqual(
         get_validated_event(e, specs),
         [
             {"why": "cd", "isError": True, "otter_msg_type": "foo-bar", "ab": "cd", "split_message": "1 of 2"},
             {"why": "another", "isError": True, "otter_msg_type": "foo-bar", "ab": "cd", "split_message": "2 of 2"},
         ],
     )
コード例 #15
0
ファイル: test_spec.py プロジェクト: manishtomar/otter
 def test_callable_spec_error(self):
     """
     Spec values will be called for errors as well, and their return will be
     used as the new value for `why`.
     """
     e = {'isError': True, 'why': 'foo-bar', 'ab': 'cd'}
     self.assertEqual(
         get_validated_event(e, specs={'foo-bar':
                                       lambda e: [(e, e['ab'])]}),
         [{
             'why': 'cd',
             'isError': True,
             'otter_msg_type': 'foo-bar',
             'ab': 'cd'
         }])
コード例 #16
0
ファイル: test_spec.py プロジェクト: stanzikratel/otter
 def test_error_no_why_but_message(self):
     """
     When error-based event does not have "why", then its message is tried
     """
     e = {"isError": True, "a": "b", "message": ("delete-server",)}
     self.assertEqual(
         get_validated_event(e),
         [
             {
                 "message": ("Deleting {server_id} server",),
                 "isError": True,
                 "why": "Deleting {server_id} server",
                 "a": "b",
                 "otter_msg_type": "delete-server",
             }
         ],
     )
コード例 #17
0
ファイル: test_spec.py プロジェクト: rackerlabs/otter
 def test_callable_spec_split_events(self):
     """
     Event dictionaries returned will have a field tracking how many events
     the original event was split into.
     """
     e = {'isError': True, 'why': 'foo-bar', 'ab': 'cd'}
     specs = {'foo-bar': lambda e: [(e, e['ab']), (e.copy(), 'another')]}
     self.assertEqual(
         get_validated_event(e, specs),
         [{'why': 'cd',
           'isError': True,
           'otter_msg_type': 'foo-bar',
           'ab': 'cd',
           'split_message': '1 of 2'},
          {'why': 'another',
           'isError': True,
           'otter_msg_type': 'foo-bar',
           'ab': 'cd',
           'split_message': '2 of 2'}])
コード例 #18
0
ファイル: test_spec.py プロジェクト: manishtomar/otter
 def test_callable_spec_split_events(self):
     """
     Event dictionaries returned will have a field tracking how many events
     the original event was split into.
     """
     e = {'isError': True, 'why': 'foo-bar', 'ab': 'cd'}
     specs = {'foo-bar': lambda e: [(e, e['ab']), (e.copy(), 'another')]}
     self.assertEqual(get_validated_event(e, specs),
                      [{
                          'why': 'cd',
                          'isError': True,
                          'otter_msg_type': 'foo-bar',
                          'ab': 'cd',
                          'split_message': '1 of 2'
                      }, {
                          'why': 'another',
                          'isError': True,
                          'otter_msg_type': 'foo-bar',
                          'ab': 'cd',
                          'split_message': '2 of 2'
                      }])
コード例 #19
0
ファイル: test_spec.py プロジェクト: stanzikratel/otter
 def test_error_not_found(self):
     """
     Nothing is changed if Error-based event is not found in msg_types
     """
     e = {"isError": True, "why": "unknown", "a": "b"}
     self.assertEqual(get_validated_event(e), [e])
コード例 #20
0
ファイル: test_spec.py プロジェクト: rackerlabs/otter
 def test_error_not_found(self):
     """
     Nothing is changed if Error-based event is not found in msg_types
     """
     e = {'isError': True, 'why': 'unknown', 'a': 'b'}
     self.assertEqual(get_validated_event(e), [e])
コード例 #21
0
ファイル: test_spec.py プロジェクト: manishtomar/otter
 def test_error_no_why_in_event(self):
     """
     If error-based event's does not have "why", then it is not changed
     """
     e = {'isError': True, 'a': 'b'}
     self.assertEqual(get_validated_event(e), [e])
コード例 #22
0
ファイル: test_spec.py プロジェクト: manishtomar/otter
 def test_msg_not_found(self):
     """
     Event is not changed if msg_type is not found
     """
     e = {'message': ('unknown', ), 'a': 'b'}
     self.assertEqual(get_validated_event(e), [e])
コード例 #23
0
ファイル: test_spec.py プロジェクト: stanzikratel/otter
 def test_msg_not_found(self):
     """
     Event is not changed if msg_type is not found
     """
     e = {"message": ("unknown",), "a": "b"}
     self.assertEqual(get_validated_event(e), [e])
コード例 #24
0
ファイル: test_spec.py プロジェクト: stanzikratel/otter
 def test_error_no_why_in_event(self):
     """
     If error-based event's does not have "why", then it is not changed
     """
     e = {"isError": True, "a": "b"}
     self.assertEqual(get_validated_event(e), [e])
コード例 #25
0
ファイル: test_spec.py プロジェクト: rackerlabs/otter
 def test_msg_not_found(self):
     """
     Event is not changed if msg_type is not found
     """
     e = {'message': ('unknown',), 'a': 'b'}
     self.assertEqual(get_validated_event(e), [e])
コード例 #26
0
ファイル: test_spec.py プロジェクト: manishtomar/otter
 def test_error_not_found(self):
     """
     Nothing is changed if Error-based event is not found in msg_types
     """
     e = {'isError': True, 'why': 'unknown', 'a': 'b'}
     self.assertEqual(get_validated_event(e), [e])