Esempio n. 1
0
 def test_get_content(self):
     datalake_file = DatalakeFile(None, uri=self.uri, type=type)
     mock_func = create_autospec(datalake_file._get_content_from_remote,
                                 return_value=self.binary_data)
     datalake_file._get_content_from_remote = mock_func
     content = datalake_file.get_content()
     self.assertEqual(content, self.binary_data)
     mock_func.assert_called_once_with()
Esempio n. 2
0
 def test_get_content_using_cache(self):
     cache_dir = '{}/{}'.format(TEST_MOUNT_DIR, self.channel_id)
     os.makedirs(cache_dir, exist_ok=True)
     with open('{}/{}'.format(cache_dir, self.file_id), 'wb') as f:
         f.write(self.binary_data)
     datalake_file = DatalakeFile(None, uri=self.uri, type=type)
     mock_func = MagicMock()
     datalake_file._get_content_from_remote = mock_func
     content = datalake_file.get_content()
     self.assertEqual(content, self.binary_data)
     mock_func.assert_not_called()
Esempio n. 3
0
 def test_get_content_from_remote(self):
     datalake_file = DatalakeFile(None, uri=self.uri, type=type)
     mock_response = self._build_content_response()
     datalake_file._do_download = MagicMock(return_value=mock_response)
     content = datalake_file._get_content_from_remote()
     self.assertEqual(content, self.binary_data)