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’')
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’')
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’')
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’')
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’’')
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)
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)
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)
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)
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)
def test_annotation_unparented(self): annotation = ast.Annotation('SomeAnnotation', 'value') self.assertEqual(annotation.format_name(), 'SomeAnnotation')