Beispiel #1
0
    def test_get_file(self):
        with patch('desktop.lib.rest.raz_http_client.AdlsRazClient.get_url'
                   ) as raz_get_url:
            with patch('desktop.lib.rest.raz_http_client.HttpClient.execute'
                       ) as http_execute:

                raz_get_url.return_value = 'sv=2014-02-14&sr=b&sig=pJL%2FWyed41tptiwBM5ymYre4qF8wzrO05tS5MCjkutc%3D&st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r'
                http_execute.return_value = 'my file content'

                client = RazHttpClient(
                    username='******',
                    base_url='https://gethue.blob.core.windows.net')
                f = client.execute(http_method='GET',
                                   path='/gethue/data/customer.csv')

                assert_equal('my file content', f)
                raz_get_url.assert_called_with(
                    action='GET',
                    path=
                    'https://gethue.blob.core.windows.net/gethue/data/customer.csv',
                    headers=None)
                http_execute.assert_called_with(
                    http_method='GET',
                    path=
                    '/gethue/data/customer.csv&sv=2014-02-14&sr=b&sig=pJL%2FWyed41tptiwBM5ymYre4qF8wzrO05tS5MCjkutc%3D&st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r',
                    params=None,
                    data=None,
                    headers=None,
                    allow_redirects=False,
                    urlencode=False,
                    files=None,
                    stream=False,
                    clear_cookies=False,
                    timeout=120)
Beispiel #2
0
    def test_handle_raz_adls_response(self):
        with patch('desktop.lib.rest.raz_http_client.AdlsRazClient.get_url'
                   ) as raz_get_url:

            # When RAZ denies request and sends no response
            raz_get_url.return_value = None
            client = RazHttpClient(
                username='******',
                base_url='https://gethue.blob.core.windows.net')

            assert_raises(PopupException,
                          client.execute,
                          http_method='GET',
                          path='/gethue/data/customer.csv',
                          params={'action': 'getStatus'})

            # When no SAS token in response
            raz_get_url.return_value = {}
            client = RazHttpClient(
                username='******',
                base_url='https://gethue.blob.core.windows.net')

            assert_raises(PopupException,
                          client.execute,
                          http_method='GET',
                          path='/gethue/data/customer.csv',
                          params={'action': 'getStatus'})
Beispiel #3
0
 def get_client(self, url):
     if RAZ.IS_ENABLED.get():
         return resource.Resource(RazHttpClient())
     else:
         return resource.Resource(
             http_client.HttpClient(url,
                                    exc_class=WebHdfsException,
                                    logger=LOG))
Beispiel #4
0
    def get_client(self, url):
        if RAZ.IS_ENABLED.get():
            client = RazHttpClient(self._user,
                                   url,
                                   exc_class=WebHdfsException,
                                   logger=LOG)
        else:
            client = http_client.HttpClient(url,
                                            exc_class=WebHdfsException,
                                            logger=LOG)

        return resource.Resource(client)
Beispiel #5
0
    def test_get_file(self):
        with patch('desktop.lib.rest.raz_http_client.AdlsRazClient.get_url'
                   ) as get_url:
            with patch('desktop.lib.rest.raz_http_client.HttpClient.execute'
                       ) as execute:

                get_url.return_value = 'https://gethue.blob.core.windows.net/hue/data/customer.csv?sv=2014-02-14&sr=b&' + \
                  'sig=pJL%2FWyed41tptiwBM5ymYre4qF8wzrO05tS5MCjkutc%3D&st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r'
                execute.return_value = 'my file'

                client = RazHttpClient()
                f = client.execute(http_method='GET',
                                   path='/gethue/data/customer.csv')

                assert_equal('my file', f)
                get_url.assert_called_with(
                    'gethue.dfs.core.windows.net',
                    'hue',
                    relative_path='/gethue/data/customer.csv',
                    perm='read')
                execute.assert_called_with(http_method='GET', path='https://gethue.blob.core.windows.net/hue/data/customer.csv?' + \
                  'sv=2014-02-14&sr=b&sig=pJL%2FWyed41tptiwBM5ymYre4qF8wzrO05tS5MCjkutc%3D&' + \
                  'st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r'
                )