コード例 #1
0
class TestCase(DefaultTestFixture):
    def setUp(self):
        DefaultTestFixture.setUp(self)
        try:
            self.root = as_internal_node('/')
            self.services = CompositeNode()
            self.services.configure({'parent': self.root, 'name': 'services'})
            self.rna_service = RNA_Tcp()
            # port = 0 indicates that the RNA Service should bind to any
            # available port.
            self.rna_service.configure({
                'parent': self.services,
                'name': 'rna',
                'port': 0,
                'enabled': 1,
                'debug': 0
            })
            self.rna_target = RNATargetNode()
            self.rna_target.configure({
                'parent': self.services,
                'name': 'RNA Target'
            })
            self.aliases = Aliases()
            self.aliases.configure({'parent': self.root, 'name': 'aliases'})
            self.root.start()
            # Determine what port the running RNA Service bound to.
            port = self.rna_service.bound_port()
            port_wait_expire_at = time.time() + 1.0
            while not port:
                self.failIf(time.time() > port_wait_expire_at,
                            "Failed to establish test's RNA port.")
                time.sleep(0.1)
                port = self.rna_service.bound_port()
            # Construct the URL explicitly using the port the RNA Service
            # bound to.
            self.rna_target_url = (
                'mpx://localhost:%d/services/RNA%%20Target' % port)
            self.alias1 = Alias()
            self.alias1.configure({
                'parent': self.aliases,
                'name': 'Remote Target',
                'node_url': self.rna_target_url
            })
        except:
            self.tearDown()
            raise
        return

    def tearDown(self):
        try:
            self.rna_target._abort = True
            self.root.prune()
            self.root = None
        finally:
            DefaultTestFixture.tearDown(self)
        return

    def test_simple_get(self):
        as_node(self.rna_target_url).get()
        return

    def test_alias_as_node(self):
        as_node('/aliases/Remote Target').get()
        return

    def test_alias_node(self):
        self.alias1.get()
        return

    ##
    # This test is essentially of "simple" MpxExceptions that occur
    # inside of the target method.  "Simple" means that there is
    # no special argument handling by the exception.
    def test_mpx_exception(self):
        try:
            as_node(self.rna_target_url).raise_eabstract()
        except EAbstract, e:
            pass
        else:
コード例 #2
0
ファイル: _test_case_rna.py プロジェクト: mcruse/monotone
class TestCase(DefaultTestFixture):
    def setUp(self):
        DefaultTestFixture.setUp(self)
        try:
            self.root = as_internal_node('/')
            self.services = CompositeNode()
            self.services.configure({'parent':self.root, 'name':'services'})
            self.rna_service = RNA_Tcp()
            # port = 0 indicates that the RNA Service should bind to any
            # available port.
            self.rna_service.configure({'parent':self.services, 'name':'rna',
                                        'port':0, 'enabled':1, 'debug':0})
            self.rna_target = RNATargetNode()
            self.rna_target.configure({'parent':self.services,
                                       'name':'RNA Target'})
            self.aliases = Aliases()
            self.aliases.configure({'parent':self.root, 'name':'aliases'})
            self.root.start()
            # Determine what port the running RNA Service bound to.
            port = self.rna_service.bound_port()
            port_wait_expire_at = time.time() + 1.0
            while not port:
                self.failIf(time.time() > port_wait_expire_at,
                            "Failed to establish test's RNA port.")
                time.sleep(0.1)
                port = self.rna_service.bound_port()
            # Construct the URL explicitly using the port the RNA Service
            # bound to.
            self.rna_target_url = (
                'mpx://localhost:%d/services/RNA%%20Target' % port
                )
            self.alias1 = Alias()
            self.alias1.configure(
                {'parent':self.aliases, 'name':'Remote Target',
                 'node_url':self.rna_target_url}
                )
        except:
            self.tearDown()
            raise
        return
    def tearDown(self):
        try:
            self.rna_target._abort = True
            self.root.prune()
            self.root = None
        finally:
            DefaultTestFixture.tearDown(self)
        return
    def test_simple_get(self):
        as_node(self.rna_target_url).get()
        return
    def test_alias_as_node(self):
        as_node('/aliases/Remote Target').get()
        return
    def test_alias_node(self):
        self.alias1.get()
        return
    ##
    # This test is essentially of "simple" MpxExceptions that occur
    # inside of the target method.  "Simple" means that there is
    # no special argument handling by the exception.
    def test_mpx_exception(self):
        try:
            as_node(self.rna_target_url).raise_eabstract()
        except EAbstract, e:
            pass
        else: