Jelajahi Sumber

Update test_provider.py

Chris Pietschmann 2 bulan lalu
induk
melakukan
2c328cc7c9
1 mengubah file dengan 10 tambahan dan 9 penghapusan
  1. 10 9
      backend/open_webui/test/apps/webui/storage/test_provider.py

+ 10 - 9
backend/open_webui/test/apps/webui/storage/test_provider.py

@@ -284,14 +284,6 @@ class TestGCSStorageProvider:
 class TestAzureStorageProvider:
 class TestAzureStorageProvider:
     @pytest.fixture(autouse=True)
     @pytest.fixture(autouse=True)
     def setup_storage(self, monkeypatch):
     def setup_storage(self, monkeypatch):
-        self.Storage = provider.AzureStorageProvider()
-        self.Storage.endpoint = "https://myaccount.blob.core.windows.net"
-        self.Storage.container_name = "my-container"
-        self.file_content = b"test content"
-        self.filename = "test.txt"
-        self.filename_extra = "test_extra.txt"
-        self.file_bytesio_empty = io.BytesIO()
-
         # Create mock Blob Service Client and related clients
         # Create mock Blob Service Client and related clients
         mock_blob_service_client = MagicMock()
         mock_blob_service_client = MagicMock()
         mock_container_client = MagicMock()
         mock_container_client = MagicMock()
@@ -312,6 +304,15 @@ class TestAzureStorageProvider:
             azure.storage.blob, "BlobClient", lambda *args, **kwargs: mock_blob_client
             azure.storage.blob, "BlobClient", lambda *args, **kwargs: mock_blob_client
         )
         )
 
 
+
+        self.Storage = provider.AzureStorageProvider()
+        self.Storage.endpoint = "https://myaccount.blob.core.windows.net"
+        self.Storage.container_name = "my-container"
+        self.file_content = b"test content"
+        self.filename = "test.txt"
+        self.filename_extra = "test_extra.txt"
+        self.file_bytesio_empty = io.BytesIO()
+
         # Apply mocks to the Storage instance
         # Apply mocks to the Storage instance
         self.Storage.blob_service_client = mock_blob_service_client
         self.Storage.blob_service_client = mock_blob_service_client
         self.Storage.container_client = mock_container_client
         self.Storage.container_client = mock_container_client
@@ -402,4 +403,4 @@ class TestAzureStorageProvider:
         # Mock behavior to raise an error for missing blobs
         # Mock behavior to raise an error for missing blobs
         self.Storage.container_client.get_blob_client().download_blob.side_effect = Exception("Blob not found")
         self.Storage.container_client.get_blob_client().download_blob.side_effect = Exception("Blob not found")
         with pytest.raises(Exception, match="Blob not found"):
         with pytest.raises(Exception, match="Blob not found"):
-            self.Storage.get_file(file_url)
+            self.Storage.get_file(file_url)