-
Notifications
You must be signed in to change notification settings - Fork 1
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
9b0cf39
commit 3d7a8df
Showing
7 changed files
with
119 additions
and
80 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 |
---|---|---|
|
@@ -5,7 +5,7 @@ x-common: &common | |
target: python_dev_deps | ||
platform: linux/amd64 | ||
environment: | ||
- DEBUG=true | ||
# - DEBUG=true | ||
- [email protected] | ||
- ADMIN_PASSWORD=123 | ||
- CACHE_URL=redis://redis:6379/1 | ||
|
@@ -18,6 +18,8 @@ x-common: &common | |
- FILE_STORAGE_DEFAULT=django.core.files.storage.FileSystemStorage | ||
- FILE_STORAGE_DNN=storages.backends.azure_storage.AzureStorage?azure_container=dnn&overwrite_files=True&connection_string=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1; | ||
- FILE_STORAGE_HOPE=storages.backends.azure_storage.AzureStorage?azure_container=hope&overwrite_files=True&connection_string=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1; | ||
- FILE_STORAGE_MEDIA=storages.backends.azure_storage.AzureStorage?azure_container=media&overwrite_files=True&connection_string=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1; | ||
- FILE_STORAGE_STATIC=storages.backends.azure_storage.AzureStorage?azure_container=static&overwrite_files=True&custom_domain=localhost:10000/&connection_string=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1; | ||
- MEDIA_ROOT=/var/hope_dedupe_engine/media | ||
- PYTHONPATH=/code/src/:/code/__pypackages__/3.12/lib/ | ||
- SECRET_KEY=very-secret-key | ||
|
@@ -98,15 +100,15 @@ services: | |
|
||
celery-worker: | ||
<<: *common | ||
entrypoint: ["sh", "-c", "exec docker-entrypoint.sh \"$0\" \"$@\""] | ||
command: worker | ||
# command: > | ||
# sh -c ' | ||
# mkdir -p /var/hope_dedupe_engine/default && | ||
# chown -R user:app /var/hope_dedupe_engine && | ||
# gosu user:app django-admin syncdnn && | ||
# gosu user:app celery -A hope_dedup_engine.config.celery worker -E --loglevel=INFO --concurrency=4 | ||
# ' | ||
# entrypoint: ["sh", "-c", "exec docker-entrypoint.sh \"$0\" \"$@\""] | ||
# command: worker | ||
command: > | ||
sh -c ' | ||
mkdir -p /var/hope_dedupe_engine/default && | ||
chown -R user:app /var/hope_dedupe_engine && | ||
gosu user:app django-admin syncdnn && | ||
gosu user:app celery -A hope_dedup_engine.config.celery worker -E --loglevel=WARNING --concurrency=4 | ||
' | ||
celery-beat: | ||
<<: *common | ||
|
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
File renamed without changes.
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,48 @@ | ||
import os | ||
from io import StringIO | ||
from unittest import mock | ||
|
||
from django.core.management import call_command | ||
|
||
import pytest | ||
from pytest_mock import MockerFixture | ||
|
||
|
||
@pytest.fixture() | ||
def environment(): | ||
return { | ||
"DEMO_IMAGES_PATH": "demo_images", | ||
"DNN_FILES_PATH": "dnn_files", | ||
} | ||
|
||
|
||
@pytest.fixture | ||
def mock_azurite_manager(mocker: MockerFixture): | ||
with mock.patch( | ||
"hope_dedup_engine.apps.core.management.commands.utils.azurite_manager.AzuriteManager" | ||
) as MockAzuriteManager: | ||
yield MockAzuriteManager | ||
|
||
|
||
def test_demo_handle_success(environment, mock_azurite_manager): | ||
out = StringIO() | ||
with ( | ||
mock.patch.dict("os.environ", environment, clear=True), | ||
mock.patch("pathlib.Path.exists", return_value=True), | ||
): | ||
call_command( | ||
"demo", | ||
demo_images="/path/to/demo/images", | ||
dnn_files="/path/to/dnn/files", | ||
stdout=out, | ||
) | ||
assert "error" not in str(out.getvalue()) | ||
assert mock_azurite_manager.call_count == 4 | ||
assert mock_azurite_manager.return_value.upload_files.call_count == 2 | ||
|
||
|
||
def test_demo_handle_exception(environment, mock_azurite_manager): | ||
mock_azurite_manager.side_effect = Exception() | ||
with mock.patch.dict(os.environ, environment, clear=True): | ||
with pytest.raises(Exception): | ||
call_command("demo", ignore_errors=False) |
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