コード例 #1
0
 def test_sequence_in_sequence_in_sequence(self):
     # This is not a legal event type since sequences need to all be the same type, however it still parses...
     expected_result = [
         1, 2, 3, ['a', 'b', 'c'], [['aa', 'bb'], ['cc', 'dd']]
     ]
     tokens = _tokenize('[1,2,3,["a","b","c"],[["aa","bb"],["cc","dd"]]]')
     parsed_package = _sequence.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #2
0
 def test_dictionary(self):
     expected_result = {
         'Thor': 'Mjolner',
         'Odin': 'Gungnir',
         'Freja': 'Falkedragt'
     }
     tokens = _tokenize(
         '{"Thor": "Mjolner", "Odin": "Gungnir", "Freja": "Falkedragt"}')
     parsed_package = _dictionary.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #3
0
 def test_event_body_all_types(self):
     expected_result = [
         'valhalla', 1, 3.14, 1.0e6, True, False, [1, 2, 3, 4], {
             'Thor': 'Mjolner',
             'Odin': 'Gungnir',
             'Freja': 'Falkedragt'
         }
     ]
     tokens = _tokenize(
         '("valhalla", 1, 3.14, 1.0e6, true, false,[1,2,3,4],'
         '{"Thor": "Mjolner", "Odin": "Gungnir", "Freja": "Falkedragt"})')
     parsed_package = _event_body.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #4
0
 def test_dictionary_in_dictionary(self):
     expected_result = {
         'other': {},
         'Weapons': {
             'Thor': 'Mjolner',
             'Odin': 'Gungnir',
             'Freja': 'Falkedragt'
         },
         'Transportation': {
             'Odin': 'Sleipner',
             'Thor': 'Goats'
         }
     }
     tokens = _tokenize(
         '{"other":{}, '
         '"Weapons": {"Thor": "Mjolner", "Odin": "Gungnir", "Freja": "Falkedragt"}, '
         '"Transportation": {"Odin": "Sleipner", "Thor": "Goats"}}')
     parsed_package = _dictionary.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #5
0
 def test_package_name(self):
     expected_result = 'heimdall.guard.rainbow.bridge.blow.horn'
     tokens = _tokenize('heimdall.guard.rainbow.bridge.blow.horn.')
     parsed_package = _package_name.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #6
0
 def test_channel(self):
     expected_result = 'channel'
     tokens = _tokenize('"channel",')
     parsed_channel = _channel.parse(tokens)
     self.assertEqual(parsed_channel, expected_result)
コード例 #7
0
 def test_empty_dictionary(self):
     expected_result = {}
     tokens = _tokenize('{}')
     parsed_package = _dictionary.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #8
0
 def test_empty_sequence_in_sequence_in_sequence(self):
     expected_result = [[[]]]
     tokens = _tokenize('[[[]]]')
     parsed_package = _sequence.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #9
0
 def test_sequence_in_sequence(self):
     expected_result = [[1, 2, 3], [4, 5, 6], [7, 8], [9]]
     tokens = _tokenize('[[1,2,3],[4,5,6],[7,8],[9]]')
     parsed_package = _sequence.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #10
0
 def test_one_item_sequence(self):
     expected_result = ['Thor']
     tokens = _tokenize('["Thor"]')
     parsed_package = _sequence.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #11
0
 def test_sequence_numbers(self):
     expected_result = [1, 2, 3, 4]
     tokens = _tokenize('[1,2,3,4]')
     parsed_package = _sequence.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #12
0
 def test_sequence_string(self):
     expected_result = ['a', 'b', 'c']
     tokens = _tokenize('["a","b","c"]')
     parsed_package = _sequence.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #13
0
 def test_event_body_simple_types(self):
     expected_result = ['valhalla', 1, 3.14, 1.0e6, True, False]
     tokens = _tokenize('("valhalla", 1, 3.14, 1.0e6, true, false)')
     parsed_package = _event_body.parse(tokens)
     self.assertEqual(parsed_package, expected_result)
コード例 #14
0
 def test_event_name(self):
     expected_result = 'ragnarok'
     tokens = _tokenize('ragnarok')
     parsed_package = _event_name.parse(tokens)
     self.assertEqual(parsed_package, expected_result)