Beispiel #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’')
Beispiel #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’')
Beispiel #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’')
Beispiel #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’')
Beispiel #5
0
 def test_duplicate(self):
     method = ast.Method('AMethod', [])
     iface = ast.Interface('Some.Interface', {
         'AMethod': method,
     })
     self.assertListEqual(iface.log.issues, [])
     duplicate_method = ast.Method('AMethod', [])
     iface.add_child(duplicate_method)
     self.assertListEqual(
         iface.log.issues,
         [(None, 'ast', 'duplicate-method',
           'Duplicate method definition ‘Some.Interface.AMethod’.')])
Beispiel #6
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’’')
Beispiel #7
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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #11
0
 def test_signal(self):
     signal = ast.Signal('SomeSignal', [])
     ast.Interface('Some.Interface', {}, {}, {
         'SomeSignal': signal,
     })
     self.assertEqual(signal.format_name(), 'Some.Interface.SomeSignal')
Beispiel #12
0
 def test_method(self):
     method = ast.Method('AMethod', [])
     ast.Interface('Some.Interface', {
         'AMethod': method,
     })
     self.assertEqual(method.format_name(), 'Some.Interface.AMethod')
Beispiel #13
0
 def test_property(self):
     prop = ast.Property('AProperty', 's', ast.Property.ACCESS_READ)
     ast.Interface('Some.Interface', {}, {
         'AProperty': prop,
     })
     self.assertEqual(prop.format_name(), 'Some.Interface.AProperty')
Beispiel #14
0
 def test_interface(self):
     iface = ast.Interface('Some.Interface')
     self.assertEqual(iface.format_name(), 'Some.Interface')