Пример #1
0
    def test_is_up_when_server_returns_False(self):
        client = BalaioRPC(using='default')

        mock_client = self.mocker.patch(client)
        mock_client.call('status')
        self.mocker.result(False)

        self.mocker.replay()

        self.assertFalse(client.is_up())
Пример #2
0
    def test_is_up_when_server_returns_False(self):
        client = BalaioRPC(using='default')

        mock_client = self.mocker.patch(client)
        mock_client.call('status')
        self.mocker.result(False)

        self.mocker.replay()

        self.assertFalse(client.is_up())
Пример #3
0
    def test_is_up_when_rpc_is_faulty(self):
        import xmlrpclib
        client = BalaioRPC(using='default')

        mock_client = self.mocker.patch(client)
        mock_client.call('status')
        self.mocker.throw(xmlrpclib.Fault('1', 'fault_str'))

        self.mocker.replay()

        self.assertFalse(client.is_up())
Пример #4
0
    def test_is_up_when_rpc_is_faulty(self):
        import xmlrpclib
        client = BalaioRPC(using='default')

        mock_client = self.mocker.patch(client)
        mock_client.call('status')
        self.mocker.throw(xmlrpclib.Fault('1', 'fault_str'))

        self.mocker.replay()

        self.assertFalse(client.is_up())
Пример #5
0
    def test_is_up_when_connection_blows(self):
        import xmlrpclib
        client = BalaioRPC(using='default')

        mock_client = self.mocker.patch(client)
        mock_client.call('status')
        self.mocker.throw(xmlrpclib.ProtocolError('url', 'headers', '1', 'errmsg'))

        self.mocker.replay()

        self.assertFalse(client.is_up())
Пример #6
0
    def test_is_up_when_connection_blows(self):
        import xmlrpclib
        client = BalaioRPC(using='default')

        mock_client = self.mocker.patch(client)
        mock_client.call('status')
        self.mocker.throw(
            xmlrpclib.ProtocolError('url', 'headers', '1', 'errmsg'))

        self.mocker.replay()

        self.assertFalse(client.is_up())
Пример #7
0
    def test_api_fullpath(self):
        balaio_api = BalaioRPC()
        api_fullpath_url = balaio_api._fullpath()
        api_fullpath_url = urlparse.urlsplit(api_fullpath_url)

        api_settings_protocol = settings.API_BALAIO['default']['PROTOCOL']
        api_settings_host = settings.API_BALAIO['default']['HOST']
        api_settings_port = settings.API_BALAIO['default']['PORT']
        api_settings_netloc = ":".join([api_settings_host, api_settings_port])
        api_settings_path = settings.API_BALAIO['default']['PATH']

        self.assertTrue(api_fullpath_url.scheme == api_settings_protocol)
        self.assertTrue(api_fullpath_url.netloc == api_settings_netloc)
        self.assertTrue(api_fullpath_url.path == '/' + api_settings_path.strip('/') + '/_rpc/')
Пример #8
0
    def test_api_fullpath(self):
        balaio_api = BalaioRPC()
        api_fullpath_url = balaio_api._fullpath()
        api_fullpath_url = urlparse.urlsplit(api_fullpath_url)

        api_settings_protocol = settings.API_BALAIO['default']['PROTOCOL']
        api_settings_host = settings.API_BALAIO['default']['HOST']
        api_settings_port = settings.API_BALAIO['default']['PORT']
        api_settings_netloc = ":".join([api_settings_host, api_settings_port])
        api_settings_path = settings.API_BALAIO['default']['PATH']

        self.assertTrue(api_fullpath_url.scheme == api_settings_protocol)
        self.assertTrue(api_fullpath_url.netloc == api_settings_netloc)
        self.assertTrue(api_fullpath_url.path == '/' +
                        api_settings_path.strip('/') + '/_rpc/')
Пример #9
0
    def test_valid_remote_call_with_args(self):
        client = BalaioRPC(using='default')

        mock_serverproxy = self.mocker.mock()
        mock_serverproxy.foo('bla')
        self.mocker.result('bar')

        mock_client = self.mocker.patch(client)
        mock_client.server_path
        self.mocker.result('http://domain.com:8086/api/v1/_rpc/')

        mock_client._xmlrpclib.ServerProxy('http://domain.com:8086/api/v1/_rpc/foo/')
        self.mocker.result(mock_serverproxy)

        self.mocker.replay()

        self.assertEqual(client.call('foo', ['bla']), 'bar')
Пример #10
0
    def test_valid_remote_call_with_args(self):
        client = BalaioRPC(using='default')

        mock_serverproxy = self.mocker.mock()
        mock_serverproxy.foo('bla')
        self.mocker.result('bar')

        mock_client = self.mocker.patch(client)
        mock_client.server_path
        self.mocker.result('http://domain.com:8086/api/v1/_rpc/')

        mock_client._xmlrpclib.ServerProxy(
            'http://domain.com:8086/api/v1/_rpc/foo/')
        self.mocker.result(mock_serverproxy)

        self.mocker.replay()

        self.assertEqual(client.call('foo', ['bla']), 'bar')
Пример #11
0
 def test_validate_correct_settings(self):
     b_client = BalaioRPC()
     self.assertTrue(b_client.validate_settings('default'))
Пример #12
0
 def test_validate_correct_settings(self):
     b_client = BalaioRPC()
     self.assertTrue(b_client.validate_settings('default'))