Beispiel #1
0
 def test_no_split_on_empty_field(self):
     """
     Do not split the event the field is an empty list, even if it is too
     long.
     """
     message = "Hello {there} human being {punctuation}"
     event = {"there": [], "punctuation": "!", "extra": "unused"}
     result = split_cf_messages(message, "there", max_length=5)(event)
     self.assertEqual(result, [(assoc(event, "there", ""), message)])
Beispiel #2
0
 def test_no_split_on_empty_field(self):
     """
     Do not split the event the field is an empty list, even if it is too
     long.
     """
     message = 'Hello {there} human being {punctuation}'
     event = {'there': [], 'punctuation': '!', 'extra': 'unused'}
     result = split_cf_messages(message, 'there', max_length=5)(event)
     self.assertEqual(result, [(assoc(event, 'there', ''), message)])
Beispiel #3
0
 def test_no_need_to_split_if_below_length(self):
     """
     Do not split the event if the message is sufficiently short.  However,
     do format it so that the list becomes a comma-separated string.
     """
     message = "Hello {there} human being {punctuation}"
     event = {"there": [1, 2, 3, 4], "punctuation": "!", "extra": "unused"}
     result = split_cf_messages(message, "there")(event)
     self.assertEqual(result, [(assoc(event, "there", "1, 2, 3, 4"), message)])
Beispiel #4
0
 def test_no_split_on_empty_field(self):
     """
     Do not split the event the field is an empty list, even if it is too
     long.
     """
     message = 'Hello {there} human being {punctuation}'
     event = {'there': [], 'punctuation': '!', 'extra': 'unused'}
     result = split_cf_messages(message, 'there', max_length=5)(event)
     self.assertEqual(result, [(assoc(event, 'there', ''), message)])
Beispiel #5
0
 def test_no_need_to_split_if_below_length(self):
     """
     Do not split the event if the message is sufficiently short.  However,
     do format it so that the list becomes a comma-separated string.
     """
     message = 'Hello {there} human being {punctuation}'
     event = {'there': [1, 2, 3, 4], 'punctuation': '!', 'extra': 'unused'}
     result = split_cf_messages(message, 'there')(event)
     self.assertEqual(result,
                      [(assoc(event, 'there', '1, 2, 3, 4'), message)])
Beispiel #6
0
 def test_no_need_to_split_if_below_length(self):
     """
     Do not split the event if the message is sufficiently short.  However,
     do format it so that the list becomes a comma-separated string.
     """
     message = 'Hello {there} human being {punctuation}'
     event = {'there': [1, 2, 3, 4], 'punctuation': '!', 'extra': 'unused'}
     result = split_cf_messages(message, 'there')(event)
     self.assertEqual(result,
                      [(assoc(event, 'there', '1, 2, 3, 4'), message)])
Beispiel #7
0
 def test_split_only_var_key(self):
     """
     Only the values for the specified key will be split, no matter how long
     the other keys are.
     """
     message = 'x: {x}, y: {y}'
     event = {'x': '123', 'y': '12345'}
     result = split_cf_messages(message, 'x', max_length=14)(event)
     self.assertEqual(result, [(assoc(event, 'x', '1'), message),
                               (assoc(event, 'x', '2'), message),
                               (assoc(event, 'x', '3'), message)])
Beispiel #8
0
 def test_split_only_var_key(self):
     """
     Only the values for the specified key will be split, no matter how long
     the other keys are.
     """
     message = "x: {x}, y: {y}"
     event = {"x": "123", "y": "12345"}
     result = split_cf_messages(message, "x", max_length=14)(event)
     self.assertEqual(
         result,
         [(assoc(event, "x", "1"), message), (assoc(event, "x", "2"), message), (assoc(event, "x", "3"), message)],
     )
Beispiel #9
0
 def test_split_only_var_key(self):
     """
     Only the values for the specified key will be split, no matter how long
     the other keys are.
     """
     message = 'x: {x}, y: {y}'
     event = {'x': '123', 'y': '12345'}
     result = split_cf_messages(message, 'x', max_length=14)(event)
     self.assertEqual(
         result,
         [(assoc(event, 'x', '1'), message),
          (assoc(event, 'x', '2'), message),
          (assoc(event, 'x', '3'), message)])