forked from breatheco-de/apiv2
-
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.
Merge branch 'development' into asset-technology-serializer
- Loading branch information
Showing
31 changed files
with
1,955 additions
and
59 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
release: export CORALOGIX_SUBSYSTEM=release; python manage.py migrate && python manage.py create_academy_roles && python manage.py set_permissions | ||
celeryworker: export CORALOGIX_SUBSYSTEM=celeryworker; export CELERY_WORKER_RUNNING=True; export REMAP_SIGTERM=SIGQUIT; newrelic-admin run-program bin/start-pgbouncer-stunnel celery -A breathecode.celery worker --loglevel=INFO | ||
web: export CORALOGIX_SUBSYSTEM=web; newrelic-admin run-program bin/start-pgbouncer-stunnel gunicorn breathecode.wsgi --timeout 29 --workers 2 --max-requests 500 --max-requests-jitter 100 --worker-class gevent | ||
celeryworker: export CORALOGIX_SUBSYSTEM=celeryworker; export CELERY_WORKER_RUNNING=True; export REMAP_SIGTERM=SIGQUIT; newrelic-admin run-program bin/start-pgbouncer-stunnel celery -A breathecode.celery worker --loglevel=INFO --concurrency 1 --prefetch-multiplier=4 --max-tasks-per-child=500 | ||
web: export CORALOGIX_SUBSYSTEM=web; newrelic-admin run-program bin/start-pgbouncer-stunnel gunicorn breathecode.wsgi --timeout 29 --workers 2 --worker-connections $WEB_WORKER_CONNECTION --max-requests-jitter 100 --worker-class gevent |
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
Empty file.
Empty file.
5 changes: 2 additions & 3 deletions
5
breathecode/commons/management/commands/garbage_collect_commons.py
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
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,54 @@ | ||
import random | ||
from unittest.mock import MagicMock, call | ||
from logging import Logger | ||
import pytest | ||
from breathecode.commons.admin import cancel | ||
from breathecode.commons import tasks | ||
|
||
from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode | ||
|
||
param_names = 'task_module,task_name,get_call_args_list' | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup(db, monkeypatch): | ||
monkeypatch.setattr('breathecode.commons.tasks.mark_task_as_cancelled.delay', MagicMock()) | ||
|
||
yield | ||
|
||
|
||
@pytest.fixture | ||
def arrange(bc: Breathecode, fake): | ||
|
||
def _arrange(n): | ||
model = bc.database.create(task_manager=n) | ||
return model, bc.database.get_model('commons.TaskManager').objects.filter() | ||
|
||
yield _arrange | ||
|
||
|
||
# When: 0 TaskManager's | ||
# Then: nothing happens | ||
def test_with_0(bc: Breathecode, arrange): | ||
_, queryset = arrange(0) | ||
|
||
res = cancel(None, None, queryset) | ||
|
||
assert res == None | ||
|
||
assert bc.database.list_of('commons.TaskManager') == [] | ||
assert tasks.mark_task_as_cancelled.delay.call_args_list == [] | ||
|
||
|
||
# When: 2 TaskManager's | ||
# Then: two tasks are scheduled | ||
def test_with_2(bc: Breathecode, arrange): | ||
|
||
model, queryset = arrange(2) | ||
|
||
res = cancel(None, None, queryset) | ||
|
||
assert res == None | ||
|
||
assert bc.database.list_of('commons.TaskManager') == bc.format.to_dict(model.task_manager) | ||
assert tasks.mark_task_as_cancelled.delay.call_args_list == [call(1), call(2)] |
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,54 @@ | ||
import random | ||
from unittest.mock import MagicMock, call | ||
from logging import Logger | ||
import pytest | ||
from breathecode.commons.admin import force_reverse | ||
from breathecode.commons import tasks | ||
|
||
from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode | ||
|
||
param_names = 'task_module,task_name,get_call_args_list' | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup(db, monkeypatch): | ||
monkeypatch.setattr('breathecode.commons.tasks.mark_task_as_reversed.delay', MagicMock()) | ||
|
||
yield | ||
|
||
|
||
@pytest.fixture | ||
def arrange(bc: Breathecode, fake): | ||
|
||
def _arrange(n): | ||
model = bc.database.create(task_manager=n) | ||
return model, bc.database.get_model('commons.TaskManager').objects.filter() | ||
|
||
yield _arrange | ||
|
||
|
||
# When: 0 TaskManager's | ||
# Then: nothing happens | ||
def test_with_0(bc: Breathecode, arrange): | ||
_, queryset = arrange(0) | ||
|
||
res = force_reverse(None, None, queryset) | ||
|
||
assert res == None | ||
|
||
assert bc.database.list_of('commons.TaskManager') == [] | ||
assert tasks.mark_task_as_reversed.delay.call_args_list == [] | ||
|
||
|
||
# When: 2 TaskManager's | ||
# Then: two tasks are scheduled | ||
def test_with_2(bc: Breathecode, arrange): | ||
|
||
model, queryset = arrange(2) | ||
|
||
res = force_reverse(None, None, queryset) | ||
|
||
assert res == None | ||
|
||
assert bc.database.list_of('commons.TaskManager') == bc.format.to_dict(model.task_manager) | ||
assert tasks.mark_task_as_reversed.delay.call_args_list == [call(1, force=True), call(2, force=True)] |
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,54 @@ | ||
import random | ||
from unittest.mock import MagicMock, call | ||
from logging import Logger | ||
import pytest | ||
from breathecode.commons.admin import pause | ||
from breathecode.commons import tasks | ||
|
||
from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode | ||
|
||
param_names = 'task_module,task_name,get_call_args_list' | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup(db, monkeypatch): | ||
monkeypatch.setattr('breathecode.commons.tasks.mark_task_as_paused.delay', MagicMock()) | ||
|
||
yield | ||
|
||
|
||
@pytest.fixture | ||
def arrange(bc: Breathecode, fake): | ||
|
||
def _arrange(n): | ||
model = bc.database.create(task_manager=n) | ||
return model, bc.database.get_model('commons.TaskManager').objects.filter() | ||
|
||
yield _arrange | ||
|
||
|
||
# When: 0 TaskManager's | ||
# Then: nothing happens | ||
def test_with_0(bc: Breathecode, arrange): | ||
_, queryset = arrange(0) | ||
|
||
res = pause(None, None, queryset) | ||
|
||
assert res == None | ||
|
||
assert bc.database.list_of('commons.TaskManager') == [] | ||
assert tasks.mark_task_as_paused.delay.call_args_list == [] | ||
|
||
|
||
# When: 2 TaskManager's | ||
# Then: two tasks are scheduled | ||
def test_with_2(bc: Breathecode, arrange): | ||
|
||
model, queryset = arrange(2) | ||
|
||
res = pause(None, None, queryset) | ||
|
||
assert res == None | ||
|
||
assert bc.database.list_of('commons.TaskManager') == bc.format.to_dict(model.task_manager) | ||
assert tasks.mark_task_as_paused.delay.call_args_list == [call(1), call(2)] |
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,54 @@ | ||
import random | ||
from unittest.mock import MagicMock, call | ||
from logging import Logger | ||
import pytest | ||
from breathecode.commons.admin import resume | ||
from breathecode.commons import tasks | ||
|
||
from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode | ||
|
||
param_names = 'task_module,task_name,get_call_args_list' | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup(db, monkeypatch): | ||
monkeypatch.setattr('breathecode.commons.tasks.mark_task_as_pending.delay', MagicMock()) | ||
|
||
yield | ||
|
||
|
||
@pytest.fixture | ||
def arrange(bc: Breathecode, fake): | ||
|
||
def _arrange(n): | ||
model = bc.database.create(task_manager=n) | ||
return model, bc.database.get_model('commons.TaskManager').objects.filter() | ||
|
||
yield _arrange | ||
|
||
|
||
# When: 0 TaskManager's | ||
# Then: nothing happens | ||
def test_with_0(bc: Breathecode, arrange): | ||
_, queryset = arrange(0) | ||
|
||
res = resume(None, None, queryset) | ||
|
||
assert res == None | ||
|
||
assert bc.database.list_of('commons.TaskManager') == [] | ||
assert tasks.mark_task_as_pending.delay.call_args_list == [] | ||
|
||
|
||
# When: 2 TaskManager's | ||
# Then: two tasks are scheduled | ||
def test_with_2(bc: Breathecode, arrange): | ||
|
||
model, queryset = arrange(2) | ||
|
||
res = resume(None, None, queryset) | ||
|
||
assert res == None | ||
|
||
assert bc.database.list_of('commons.TaskManager') == bc.format.to_dict(model.task_manager) | ||
assert tasks.mark_task_as_pending.delay.call_args_list == [call(1), call(2)] |
Oops, something went wrong.