Ejemplo n.º 1
0
    def test_get_str_prefix(self):
        # Signature: name(self, join_char='_')
                # Returns the same as ``getstr``, but prepends the ``join_char`` to
                # the end of the string, so that the string can be used to prefix
                # variables.
                #
                # :param join_char: The character used to join the levels in the address.
        # from nineml.abstraction_layer.component.namespaceaddress import NamespaceAddress

        self.assertEqual(
            NSA('a.b.c.d.e.f.g.h.i').get_str_prefix('.'),
            'a.b.c.d.e.f.g.h.i.'
        )

        self.assertEqual(
            NSA.concat(NSA.create_root(), NSA.create_root(),
                       NSA('a.b.c.d.e.f.g.h.i')).get_str_prefix('.'),
            'a.b.c.d.e.f.g.h.i.'
        )

        self.assertEqual(
            NSA.concat(NSA.create_root(), NSA.create_root(),
                       NSA('a.b.c.d.e.f.g.h.i'), NSA.create_root(),).get_str_prefix('.'),
            'a.b.c.d.e.f.g.h.i.'
        )

        self.assertEqual(
            NSA('a.b.c.d.e.f.g.h.i').get_str_prefix('/'),
            'a/b/c/d/e/f/g/h/i/'
        )
Ejemplo n.º 2
0
    def test_getstr(self):
        # Signature: name(self, join_char='_')
                # Returns the namespace address as a string.
                #
                # :param join_char: The character used to join the levels in the address.
        # from nineml.abstraction_layer.component.namespaceaddress import NamespaceAddress

        self.assertEqual(
            NSA('a.b.c.d.e.f.g.h.i').getstr('.'),
            'a.b.c.d.e.f.g.h.i'
        )

        self.assertEqual(
            NSA.concat(NSA.create_root(), NSA.create_root(), NSA(
                       'a.b.c.d.e.f.g.h.i')).getstr('.'),
            'a.b.c.d.e.f.g.h.i'
        )

        self.assertEqual(
            NSA.concat(NSA.create_root(), NSA.create_root(), NSA(
                       'a.b.c.d.e.f.g.h.i'), NSA.create_root(),).getstr('.'),
            'a.b.c.d.e.f.g.h.i'
        )

        self.assertEqual(
            NSA('a.b.c.d.e.f.g.h.i').getstr('/'),
            'a/b/c/d/e/f/g/h/i'
        )
Ejemplo n.º 3
0
    def test_get_str_prefix(self):
        # Signature: name(self, join_char='_')
        # Returns the same as ``getstr``, but prepends the ``join_char`` to
        # the end of the string, so that the string can be used to prefix
        # variables.
        #
        # :param join_char: The character used to join the levels in the address.
        # from nineml.abstraction_layer.component.namespaceaddress import NamespaceAddress

        self.assertEqual(
            NSA('a.b.c.d.e.f.g.h.i').get_str_prefix('.'), 'a.b.c.d.e.f.g.h.i.')

        self.assertEqual(
            NSA.concat(NSA.create_root(), NSA.create_root(),
                       NSA('a.b.c.d.e.f.g.h.i')).get_str_prefix('.'),
            'a.b.c.d.e.f.g.h.i.')

        self.assertEqual(
            NSA.concat(
                NSA.create_root(),
                NSA.create_root(),
                NSA('a.b.c.d.e.f.g.h.i'),
                NSA.create_root(),
            ).get_str_prefix('.'), 'a.b.c.d.e.f.g.h.i.')

        self.assertEqual(
            NSA('a.b.c.d.e.f.g.h.i').get_str_prefix('/'), 'a/b/c/d/e/f/g/h/i/')
Ejemplo n.º 4
0
    def test_getstr(self):
        # Signature: name(self, join_char='_')
        # Returns the namespace address as a string.
        #
        # :param join_char: The character used to join the levels in the address.
        # from nineml.abstraction_layer.component.namespaceaddress import NamespaceAddress

        self.assertEqual(
            NSA('a.b.c.d.e.f.g.h.i').getstr('.'), 'a.b.c.d.e.f.g.h.i')

        self.assertEqual(
            NSA.concat(NSA.create_root(), NSA.create_root(),
                       NSA('a.b.c.d.e.f.g.h.i')).getstr('.'),
            'a.b.c.d.e.f.g.h.i')

        self.assertEqual(
            NSA.concat(
                NSA.create_root(),
                NSA.create_root(),
                NSA('a.b.c.d.e.f.g.h.i'),
                NSA.create_root(),
            ).getstr('.'), 'a.b.c.d.e.f.g.h.i')

        self.assertEqual(
            NSA('a.b.c.d.e.f.g.h.i').getstr('/'), 'a/b/c/d/e/f/g/h/i')
Ejemplo n.º 5
0
 def test_concat(self):
     # Signature: name(cls, *args)
     # Concatenates all the Namespace Addresses.
     #
     # This method take all the arguments supplied, converts each one into a
     # namespace object, then, produces a new namespace object which is the
     # concatentation of all the arugements namespaces.
     #
     # For example:
     #
     # >>> NamespaceAddress.concat('first.second','third.forth','fifth.sixth')
     #     NameSpaceAddress: '/first/second/third/forth/fifth/sixth'
     # from nineml.abstraction_layer.component.namespaceaddress import NamespaceAddress
     self.assertEqual(NSA.concat(NSA('a.b.c'), NSA('d.e.f'), NSA('g.h.i')),
                      NSA('a.b.c.d.e.f.g.h.i'))
     self.assertEqual(
         NSA.concat(NSA.create_root(), NSA('a.b.c'), NSA.create_root()),
         NSA('a.b.c'))
     self.assertEqual(NSA.concat(NSA.create_root(), NSA.create_root()),
                      NSA.create_root())
Ejemplo n.º 6
0
 def test_concat(self):
     # Signature: name(cls, *args)
             # Concatenates all the Namespace Addresses.
             #
             # This method take all the arguments supplied, converts each one into a
             # namespace object, then, produces a new namespace object which is the
             # concatentation of all the arugements namespaces.
             #
             # For example:
             #
             # >>> NamespaceAddress.concat('first.second','third.forth','fifth.sixth')
             #     NameSpaceAddress: '/first/second/third/forth/fifth/sixth'
     # from nineml.abstraction_layer.component.namespaceaddress import NamespaceAddress
     self.assertEqual(
         NSA.concat(NSA('a.b.c'), NSA('d.e.f'), NSA('g.h.i')),
         NSA('a.b.c.d.e.f.g.h.i'))
     self.assertEqual(
         NSA.concat(NSA.create_root(), NSA('a.b.c'), NSA.create_root()),
         NSA('a.b.c')
     )
     self.assertEqual(
         NSA.concat(NSA.create_root(), NSA.create_root()),
         NSA.create_root()
     )