Skip to content

Backend test suite seems broken? #5

Description

@achiang

Trying to get the backend test suite working... using the following diff:

diff --git a/docker-compose.yaml b/docker-compose.yaml
index 6e3806c..6cff7d7 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -66,6 +45,15 @@ services:
     volumes:
       - .:/flask/src
 
+  pytest:
+    build:
+      context: .
+      dockerfile: ./docker/backend/Dockerfile
+    entrypoint:
+      - /test-entrypoint.sh
+    volumes:
+      - .:/flask/src
+
   redis:
     image: redis:3.2-alpine
     command: redis-server
diff --git a/docker/backend/Dockerfile b/docker/backend/Dockerfile
index 902b258..f1deb9d 100644
--- a/docker/backend/Dockerfile
+++ b/docker/backend/Dockerfile
@@ -24,3 +15,4 @@ COPY ./docker/backend/docs-entrypoint.sh /
 COPY ./docker/backend/celery-beat-entrypoint.sh /
 COPY ./docker/backend/celery-worker-entrypoint.sh /
 COPY ./docker/backend/flask-entrypoint.sh /flask-entrypoint.sh
+COPY ./docker/backend/test-entrypoint.sh /test-entrypoint.sh

And then:

$ cat docker/backend/test-entrypoint.sh
#!/bin/sh

tox

The output of docker-compose up --build pytest results in:

pytest_1         | py36 run-test-pre: PYTHONHASHSEED='3866487884'
pytest_1         | py36 runtests: commands[0] | py.test
pytest_1         | ============================= test session starts ==============================
pytest_1         | platform linux -- Python 3.6.6, pytest-4.2.0, py-1.7.0, pluggy-0.8.1
pytest_1         | cachedir: .tox/py36/.pytest_cache
pytest_1         | rootdir: /flask/src, inifile: pytest.ini
pytest_1         | plugins: flask-0.14.0, Flask-Unchained-0.7.0, celery-4.2.1
pytest_1         | collected 51 items
pytest_1         | 
pytest_1         | tests/security/views/test_change_password.py EEEEEE
pytest_1         | tests/security/views/test_check_auth_token.py E
pytest_1         | tests/security/views/test_confirm_email.py EEE
pytest_1         | tests/security/views/test_forgot_password.py EEEE
pytest_1         | tests/security/views/test_login.py EEEEEEE
pytest_1         | tests/security/views/test_logout.py EE
pytest_1         | tests/security/views/test_resend_confirmation_email.py EEE
pytest_1         | tests/security/views/test_reset_password.py EEEEEE
pytest_1         | tests/security/views/test_user_resource.py EEEEEEEEEEEEE
pytest_1         | tests/site/models/test_contact_submission.py EEE
pytest_1         | tests/site/serializers/test_contact_submission_serializers.py E
pytest_1         | tests/site/views/test_contact_submission_resource.py EE
pytest_1         | 
pytest_1         | ==================================== ERRORS ====================================
pytest_1         | ___________ ERROR at setup of TestChangePassword.test_auth_required ____________
pytest_1         | 
pytest_1         | request = <SubRequest 'app' for <Function test_auth_required>>
pytest_1         | 
pytest_1         |     @pytest.fixture(autouse=True, scope='session')
pytest_1         |     def app(request):
pytest_1         |         """
pytest_1         |         Automatically used test fixture. Returns the application instance-under-test with
pytest_1         |         a valid app context.
pytest_1         |         """
pytest_1         |         unchained._reset()
pytest_1         |     
pytest_1         |         options = {}
pytest_1         |         for mark in request.node.iter_markers('options'):
pytest_1         |             kwargs = getattr(mark, 'kwargs', {})
pytest_1         |             options.update({k.upper(): v for k, v in kwargs.items()})
pytest_1         |     
pytest_1         | >       app = AppFactory.create_app(TEST, _config_overrides=options)
pytest_1         | 
pytest_1         | .tox/py36/lib/python3.6/site-packages/flask_unchained/pytest.py:57: 
pytest_1         | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pytest_1         | .tox/py36/lib/python3.6/site-packages/flask_unchained/app_factory.py:75: in create_app
pytest_1         |     unchained.init_app(app, env, bundles, _config_overrides=_config_overrides)
pytest_1         | .tox/py36/lib/python3.6/site-packages/flask_unchained/unchained.py:107: in init_app
pytest_1         |     run_hooks_hook.run_hook(app, bundles, _config_overrides=_config_overrides)
pytest_1         | .tox/py36/lib/python3.6/site-packages/flask_unchained/hooks/run_hooks_hook.py:34: in run_hook
pytest_1         |     hook.run_hook(app, bundles)
pytest_1         | .tox/py36/lib/python3.6/site-packages/flask_unchained/app_factory_hook.py:98: in run_hook
pytest_1         |     self.process_objects(app, self.collect_from_bundles(bundles))
pytest_1         | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pytest_1         | 
pytest_1         | self = <flask_unchained.bundles.api.hooks.register_serializers_hook.RegisterSerializersHook object at 0x7f03701da160>
pytest_1         | app = <FlaskUnchained 'backend'>
pytest_1         | objects = {'ArticleListSerializer': <class 'bundles.blog.serializers.article_serializer.ArticleListSerializer'>, 'ArticleSeriali..., 'ArticleSeriesSerializer': <class 'bundles.blog.serializers.series_article_serializer.ArticleSeriesSerializer'>, ...}
pytest_1         | 
pytest_1         |     def process_objects(self, app: Flask, objects):
pytest_1         |         for name, serializer in objects.items():
pytest_1         |             self.bundle.serializers[name] = serializer
pytest_1         |             class_registry.register(name, serializer)
pytest_1         |     
pytest_1         |             model = serializer.Meta.model
pytest_1         | >           model_name = model if isinstance(model, str) else model.__name__
pytest_1         | E           AttributeError: 'NoneType' object has no attribute '__name__'
pytest_1         | 
pytest_1         | .tox/py36/lib/python3.6/site-packages/flask_unchained/bundles/api/hooks/register_serializers_hook.py:31: AttributeError

This could very well be a setup error on my part, not really sure. Any hints appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions