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_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’.')])
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_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_signal(self): signal = ast.Signal('SomeSignal', []) ast.Interface('Some.Interface', {}, {}, { 'SomeSignal': signal, }) self.assertEqual(signal.format_name(), 'Some.Interface.SomeSignal')
def test_method(self): method = ast.Method('AMethod', []) ast.Interface('Some.Interface', { 'AMethod': method, }) self.assertEqual(method.format_name(), 'Some.Interface.AMethod')
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')
def test_interface(self): iface = ast.Interface('Some.Interface') self.assertEqual(iface.format_name(), 'Some.Interface')