def test_package_many_levels(self): expected_event = ApamaEvent( package_name='heimdall.guard.rainbow.bridge.blow.horn', event_name='ragnarok') parsed_event = parse( 'heimdall.guard.rainbow.bridge.blow.horn.ragnarok()') self.assertEqual(parsed_event, expected_event)
def test_simple_fields(self): expected_event = ApamaEvent( package_name='heimdall.horn', event_name='ragnarok', fields=['valhalla', 1, 3.14, 1.0e6, False, True]) parsed_event = parse( 'heimdall.horn.ragnarok("valhalla", 1, 3.14, 1.0e6, false, true)') self.assertEqual(parsed_event, expected_event)
def test_readme_example(self): expected_event = ApamaEvent(package_name='com.apama', event_name='Event', fields=[ 'Field', 1.234, 7, False, ['a', 'b', 'c'], { 'key': 'value' } ]) parsed_event = parse( 'com.apama.Event("Field", 1.234, 7, false, ["a","b","c"], {"key": "value"})' ) self.assertEqual(parsed_event, expected_event)
def test_nested_event(self): expected_event = ApamaEvent(channel='channel', package_name='heimdall.horn', event_name='ragnarok', fields=[ ApamaEvent( package_name='rainbow.bridge', event_name='breached', fields=[True]) ]) parsed_event = parse( '"channel",heimdall.horn.ragnarok(rainbow.bridge.breached(true))') self.assertEqual(parsed_event, expected_event)
def test_no_event(self): expected_event = None parsed_event = parse('') self.assertEqual(parsed_event, expected_event)
def test_package_two_levels(self): expected_event = ApamaEvent(package_name='heimdall.horn', event_name='ragnarok') parsed_event = parse('heimdall.horn.ragnarok()') self.assertEqual(parsed_event, expected_event)
def test_simple_event(self): expected_event = ApamaEvent(event_name='a') parsed_event = parse('a()') self.assertEqual(parsed_event, expected_event)
def test_unparse_event(self): event = 'com.apama.Event("Field", 1.234, 7, false, ["a","b","c"], ' \ '{"key":"value","key1":"value1","key2":"value2"})' parsed_event = parse(event) self.assertEqual(parsed_event.unparse(), event)
def test_unparse_event_with_channel(self): event = '"channel",heimdall.horn.ragnarok("valhalla", 1, 3.14, 1000000, false, true)' parsed_event = parse(event) self.assertEqual(parsed_event.unparse(), event)