Ejemplo n.º 1
0
    def test_constructor(self):
        test_strings = {
            'normal': "Tag1,Tag2",
            'normalParen': "(Tag1,Tag2)",
            'normalDoubleParen': "(Tag1,Tag2,(Tag3,Tag4))",
            'extraOpeningParen': "((Tag1,Tag2,(Tag3,Tag4))",
            'extra2OpeningParen': "(((Tag1,Tag2,(Tag3,Tag4))",
            'extraClosingParen': "(Tag1,Tag2,(Tag3,Tag4)))",
            'extra2ClosingParen': "(Tag1,Tag2,(Tag3,Tag4))))"
        }
        expected_result = {
            'normal': True,
            'normalParen': True,
            'normalDoubleParen': True,
            'extraOpeningParen': False,
            'extra2OpeningParen': False,
            'extraClosingParen': False,
            'extra2ClosingParen': False
        }

        # Just make sure it doesn't crash while parsing super invalid strings.
        for name, string in test_strings.items():
            hed_string = HedString(string)

            self.assertEqual(bool(hed_string), expected_result[name])
            if bool(hed_string):
                _ = hed_string.get_all_groups()
                _ = hed_string.get_all_tags()
Ejemplo n.º 2
0
 def test_parsed_tags(self):
     hed_string = '/Action/Reach/To touch,(/Attribute/Object side/Left,/Participant/Effect/Body part/Arm),' \
                  '/Attribute/Location/Screen/Top/70 px,/Attribute/Location/Screen/Left/23 px '
     parsed_string = HedString(hed_string)
     self.assertCountEqual(
         [str(tag) for tag in parsed_string.get_all_tags()], [
             '/Action/Reach/To touch',
             '/Attribute/Object side/Left',
             '/Participant/Effect/Body part/Arm',
             '/Attribute/Location/Screen/Top/70 px',
             '/Attribute/Location/Screen/Left/23 px',
         ])
     self.assertCountEqual([
         str(group) for group in parsed_string.get_all_groups()
     ], [
         '/Action/Reach/To touch,(/Attribute/Object side/Left,/Participant/Effect/Body part/Arm),'
         '/Attribute/Location/Screen/Top/70 px,/Attribute/Location/Screen/Left/23 px',
         '(/Attribute/Object side/Left,/Participant/Effect/Body part/Arm)'
     ])