Skip to content

Commit

Permalink
Add Spinach worker fixture. (#2404)
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez authored Nov 1, 2019
1 parent 172d7f1 commit 8a176a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ norecursedirs = .git .* static __pycache__ build
DJANGO_SETTINGS_MODULE = server.tests.settings
python_files = tests.py test_*.py *_tests.py
testpaths = server
addopts = -rsxX --showlocals --tb=native --nomigrations --flake8 --staticfiles --isort --cov-report term --cov-report xml --cov server
addopts = -rsxX --showlocals --tb=native --reuse-db --nomigrations --flake8 --staticfiles --isort --cov-report term --cov-report xml --cov server
env =
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
Expand Down
18 changes: 18 additions & 0 deletions server/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import datetime
import logging
import time

import pytest
from rest_framework.test import APIClient
from spinach.contrib.spinachd.apps import spin

from server.base.models import User
from server.files.models import File, FileSource
from server.notebooks.models import Notebook, NotebookRevision

logger = logging.getLogger(__name__)


def pytest_configure(config):
# work-around for https://github.com/ktosiek/pytest-freezegun/issues/13
Expand All @@ -16,6 +21,19 @@ def pytest_configure(config):
)


@pytest.fixture(scope="session", autouse=True)
def spinach_worker(request):
spin.start_workers(number=1, block=False)
logger.info("Starting Spinach workers.")

def stop_workers():
spin.stop_workers()
logging.info("Stopping Spinach workers.")
time.sleep(2)

request.addfinalizer(stop_workers)


@pytest.fixture
def api_client():
"""
Expand Down

0 comments on commit 8a176a4

Please sign in to comment.