예제 #1
0
 def test_annotation_interface(self):
     annotation = ast.Annotation('SomeAnnotation', 'value')
     ast.Interface('Some.Interface', {}, {}, {}, {
         'SomeAnnotation': annotation,
     })
     self.assertEqual(annotation.format_name(),
                      'SomeAnnotation of ‘Some.Interface’')
예제 #2
0
 def test_annotation_property(self):
     annotation = ast.Annotation('SomeAnnotation', 'value')
     prop = ast.Property('AProperty', 's', ast.Property.ACCESS_READ, {
         'SomeAnnotation': annotation,
     })
     ast.Interface('Some.Interface', {}, {
         'AProperty': prop,
     })
     self.assertEqual(annotation.format_name(),
                      'SomeAnnotation of ‘Some.Interface.AProperty’')
예제 #3
0
 def test_annotation_signal(self):
     annotation = ast.Annotation('SomeAnnotation', 'value')
     signal = ast.Signal('ASignal', [], {
         'SomeAnnotation': annotation,
     })
     ast.Interface('Some.Interface', {}, {}, {
         'ASignal': signal,
     })
     self.assertEqual(annotation.format_name(),
                      'SomeAnnotation of ‘Some.Interface.ASignal’')
예제 #4
0
 def test_annotation_method(self):
     annotation = ast.Annotation('SomeAnnotation', 'value')
     method = ast.Method('AMethod', [], {
         'SomeAnnotation': annotation,
     })
     ast.Interface('Some.Interface', {
         'AMethod': method,
     })
     self.assertEqual(annotation.format_name(),
                      'SomeAnnotation of ‘Some.Interface.AMethod’')
예제 #5
0
 def test_annotation_argument(self):
     annotation = ast.Annotation('SomeAnnotation', 'value')
     arg = ast.Argument('Argument', ast.Argument.DIRECTION_IN, 's', {
         'SomeAnnotation': annotation,
     })
     method = ast.Method('AMethod', [arg])
     ast.Interface('Some.Interface', {
         'AMethod': method,
     })
     self.assertEqual(
         annotation.format_name(), 'SomeAnnotation of ‘0 (‘Argument’)'
         ' of method ‘Some.Interface.AMethod’’')
예제 #6
0
    def test_walk(self):
        annotation = ast.Annotation('SomeAnnotation', 'value')
        method = ast.Method('AMethod', [], {
            'SomeAnnotation': annotation,
        })
        iface = ast.Interface('Some.Interface', {
            'AMethod': method,
        })

        children = [node for node in iface.walk()]
        self.assertEquals(len(children), 2)
        self.assertEquals(children[0], method)
        self.assertEquals(children[1], annotation)
예제 #7
0
    def test_argument(self):
        annotation = ast.Annotation('SomeAnnotation', 'value')
        self.assertEqual(annotation.parent, None)

        arg = ast.Argument('SomeArgument', ast.Argument.DIRECTION_IN, 's', {
            'SomeAnnotation': annotation,
        })
        self.assertEqual(arg.parent, None)
        self.assertEqual(arg.index, -1)
        self.assertEqual(annotation.parent, arg)

        method = ast.Method('AMethod', [arg])
        self.assertEqual(arg.parent, method)
        self.assertEqual(arg.index, 0)
예제 #8
0
    def test_signal(self):
        annotation = ast.Annotation('SomeAnnotation', 'value')
        self.assertEqual(annotation.parent, None)

        signal = ast.Signal('ASignal', [], {
            'SomeAnnotation': annotation,
        })
        self.assertEqual(signal.interface, None)
        self.assertEqual(annotation.parent, signal)

        iface = ast.Interface('Some.Interface', {}, {
            'ASignal': signal,
        })
        self.assertEqual(signal.interface, iface)
예제 #9
0
    def test_method(self):
        annotation = ast.Annotation('SomeAnnotation', 'value')
        self.assertEqual(annotation.parent, None)

        method = ast.Method('AMethod', [], {
            'SomeAnnotation': annotation,
        })
        self.assertEqual(method.interface, None)
        self.assertEqual(annotation.parent, method)

        iface = ast.Interface('Some.Interface', {
            'AMethod': method,
        })
        self.assertEqual(method.interface, iface)
예제 #10
0
    def test_property(self):
        annotation = ast.Annotation('SomeAnnotation', 'value')
        self.assertEqual(annotation.parent, None)

        prop = ast.Property('AProperty', 's', ast.Property.ACCESS_READ, {
            'SomeAnnotation': annotation,
        })
        self.assertEqual(prop.interface, None)
        self.assertEqual(annotation.parent, prop)

        iface = ast.Interface('Some.Interface', {}, {
            'AProperty': prop,
        })
        self.assertEqual(prop.interface, iface)
예제 #11
0
 def test_annotation_unparented(self):
     annotation = ast.Annotation('SomeAnnotation', 'value')
     self.assertEqual(annotation.format_name(), 'SomeAnnotation')