-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b9fd2d
commit 4f17819
Showing
6 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,10 @@ Kubernetes | |
``` | ||
kubectl create -f deployment/minio.yml | ||
``` | ||
|
||
### Tests | ||
|
||
Run tests | ||
``` | ||
pytest app/tests/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-r requirements.txt | ||
pytest==7.4.4 | ||
pytest-mock==3.12.0 |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pytest | ||
from src.helpers.storage.minio import MinioClient | ||
|
||
@pytest.fixture | ||
def minio_client(): | ||
endpoint_url = 'http://localhost:9000' | ||
access_key = 'minio_access_key' | ||
secret_key = 'minio_secret_key' | ||
return MinioClient(endpoint_url, access_key, secret_key) | ||
|
||
def test_create_bucket(mocker, minio_client): | ||
mock_s3 = mocker.patch.object(minio_client.s3_client, 'create_bucket') | ||
minio_client.create_bucket('testbucket') | ||
mock_s3.assert_called_once_with(Bucket='testbucket') | ||
|
||
def test_upload_file(mocker, minio_client): | ||
mock_upload_file = mocker.patch.object(minio_client.s3_client, 'upload_file') | ||
minio_client.upload_file('testbucket', 'test.txt', '/path/to/test.txt') | ||
mock_upload_file.assert_called_once_with('/path/to/test.txt', 'testbucket', 'test.txt') | ||
|
||
def test_download_file(mocker, minio_client): | ||
mock_download_file = mocker.patch.object(minio_client.s3_client, 'download_file') | ||
minio_client.download_file('testbucket', 'test.txt', '/path/to/downloaded/test.txt') | ||
mock_download_file.assert_called_once_with('testbucket', 'test.txt', '/path/to/downloaded/test.txt') | ||
|
||
def test_delete_file(mocker, minio_client): | ||
mock_delete_object = mocker.patch.object(minio_client.s3_client, 'delete_object') | ||
minio_client.delete_file('testbucket', 'test.txt') | ||
mock_delete_object.assert_called_once_with(Bucket='testbucket', Key='test.txt') | ||
|
||
def test_delete_bucket(mocker, minio_client): | ||
mock_delete_bucket = mocker.patch.object(minio_client.s3_client, 'delete_bucket') | ||
minio_client.delete_bucket('testbucket') | ||
mock_delete_bucket.assert_called_once_with(Bucket='testbucket') |