-
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
Showing
6 changed files
with
66 additions
and
17 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 |
---|---|---|
|
@@ -3,18 +3,34 @@ | |
volumes: | ||
static-data: | ||
media-data: | ||
minio-data: | ||
|
||
# Exactly the same as production but for dev env, we expose the port and uses | ||
# different port for the web. | ||
version: '3.4' | ||
services: | ||
|
||
minio: | ||
image: quay.io/minio/minio:RELEASE.2024-03-30T09-41-56Z.fips | ||
command: minio server /data --console-address ":9001" | ||
ports: | ||
- "9010:9000" | ||
- "9011:9001" | ||
environment: | ||
- MINIO_ROOT_USER=minio_user | ||
- MINIO_ROOT_PASSWORD=minio_password | ||
- MINIO_HTTP_TRACE | ||
volumes: | ||
- minio-data:/data | ||
restart: always | ||
|
||
dev: | ||
image: ${APP_IMAGE}:dev | ||
container_name: "dev" | ||
links: | ||
- db | ||
- redis | ||
- minio | ||
volumes: | ||
- static-data:/home/web/static | ||
- media-data:/home/web/media | ||
|
@@ -41,6 +57,13 @@ services: | |
- [email protected] | ||
- SENTRY_DSN= | ||
- SENTRY_ENVIRONMENT=staging | ||
|
||
# Minio | ||
- MINIO_AWS_ACCESS_KEY_ID=minio_user | ||
- MINIO_AWS_SECRET_ACCESS_KEY=minio_password | ||
- MINIO_AWS_ENDPOINT_URL=http://minio:9000/ | ||
- MINIO_AWS_BUCKET_NAME=tomorrownow | ||
- MINIO_AWS_DIR_PREFIX=dev/media | ||
entrypoint: [ ] | ||
ports: | ||
# for django test server | ||
|
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
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,37 @@ | ||
# coding=utf-8 | ||
""" | ||
Tomorrow Now GAP. | ||
.. note:: Unit test for S3 utils. | ||
""" | ||
import os | ||
|
||
from django.core.files.base import ContentFile | ||
from django.core.files.storage import default_storage | ||
from django.test import TestCase | ||
|
||
from core.utils.s3 import zip_folder_in_s3, remove_s3_folder | ||
|
||
|
||
class TestS3Utilities(TestCase): | ||
"""Test S3 utilities.""" | ||
|
||
def test_zip_folder_in_s3(self): | ||
"""Test zip folder in S3.""" | ||
folder = 'test_folder' | ||
remove_s3_folder(default_storage, folder) | ||
default_storage.save( | ||
os.path.join(folder, 'test'), ContentFile(b"new content") | ||
) | ||
default_storage.save( | ||
os.path.join(folder, 'test_2'), ContentFile(b"new content") | ||
) | ||
zip_folder_in_s3( | ||
default_storage, folder, 'test_folder.zip' | ||
) | ||
self.assertTrue( | ||
default_storage.exists('test_folder.zip') | ||
) | ||
self.assertFalse( | ||
default_storage.exists(folder) | ||
) |
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
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
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