Skip to content

Commit

Permalink
[#51] Fixed testapp (see README for instructions)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart van der Schoor committed Feb 29, 2024
1 parent e336b21 commit faab3a7
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ mail_editor.egg-info
coverage\.xml

junit\.xml

testapp/mail_editor.db
35 changes: 29 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ You can set template variables to all of the mail templates in the following fas

.. code:: python
# static dictionary
MAIL_EDITOR_BASE_CONTEXT = {
'url': 'http://www.maykinmedia.nl',
}
# static dictionary
MAIL_EDITOR_BASE_CONTEXT = {
'url': 'http://www.maykinmedia.nl',
}
# import path to callable that returns a dictionary
MAIL_EDITOR_DYNAMIC_CONTEXT = "dotted.path.to.callable"
# import path to callable that returns a dictionary
MAIL_EDITOR_DYNAMIC_CONTEXT = "dotted.path.to.callable"
Installation
Expand All @@ -180,6 +180,29 @@ Install with pip:
pip install mail_editor
Local development
-----------------

To install and develop the library locally, use::

.. code-block:: bash
pip install -e .[tests,coverage,docs,release]
When running management commands via ``django-admin``, make sure to add the root
directory to the python path (or use ``python -m django <command>``):

.. code-block:: bash
export PYTHONPATH=. DJANGO_SETTINGS_MODULE=testapp.settings
django-admin check
# or other commands like:
django-admin migrate
django-admin createsuperuser
django-admin runserver
# django-admin makemessages -l nl
.. _Django Yubin: https://github.com/APSL/django-yubin
.. _Sergei Maertens: https://github.com/sergei-maertens
.. _langerak-gkv: https://github.com/sergei-maertens/langerak-gkv/blob/master/src/langerak_gkv/mailing/mail_template.py
Expand Down
4 changes: 4 additions & 0 deletions fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ isort --profile black ./tests
autoflake --in-place --remove-all-unused-imports -r ./tests
black ./tests


isort --profile black ./testapp
autoflake --in-place --remove-all-unused-imports -r ./testapp
black ./testapp
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ sections=["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER

[tool.pytest.ini_options]
testpaths = ["tests"]
DJANGO_SETTINGS_MODULE = "tests.settings"
DJANGO_SETTINGS_MODULE = "testapp.settings"

[tool.bumpversion]
current_version = "0.3.5"
Expand Down
Empty file added testapp/__init__.py
Empty file.
File renamed without changes
14 changes: 9 additions & 5 deletions tests/settings.py → testapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

SECRET_KEY = "supersekrit"

USE_TZ = True

DEBUG = True

DATABASES = {
"default": {
# Memory resident database, for easy testing.
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
"NAME": os.path.join(DJANGO_PROJECT_DIR, "mail_editor.db"),
}
}

Expand All @@ -20,11 +24,12 @@
"django.contrib.admin",
"mail_editor",
"ckeditor",
"testapp",
]

EMAIL_BACKEND = "django.core.mail.backends.dummy.EmailBackend"

ROOT_URLCONF = "tests.urls"
ROOT_URLCONF = "testapp.urls"

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
Expand Down Expand Up @@ -77,7 +82,6 @@
"models.W042", # AutoField warning not relevant for tests
]


STATICFILES_DIRS = [
os.path.join(DJANGO_PROJECT_DIR, "static"),
os.path.join(DJANGO_PROJECT_DIR, "static_alternative"),
Expand All @@ -90,6 +94,6 @@
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(os.path.dirname(__file__), "static")
STATIC_ROOT = os.path.join(DJANGO_PROJECT_DIR, "static")
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media")
MEDIA_ROOT = os.path.join(DJANGO_PROJECT_DIR, "media")
File renamed without changes.
File renamed without changes
File renamed without changes
13 changes: 13 additions & 0 deletions testapp/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import include, path

urlpatterns = [
path("maileditor/", include("mail_editor.urls")),
path("admin/", admin.site.urls),
]
urlpatterns += staticfiles_urlpatterns() + static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
)
10 changes: 0 additions & 10 deletions tests/manage.py

This file was deleted.

7 changes: 0 additions & 7 deletions tests/urls.py

This file was deleted.

4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DJANGO =

[testenv]
setenv =
DJANGO_SETTINGS_MODULE=tests.settings
DJANGO_SETTINGS_MODULE=testapp.settings
PYTHONPATH={toxinidir}
extras =
tests
Expand All @@ -40,7 +40,7 @@ commands = isort --check-only --diff .
[testenv:black]
extras = tests
skipsdist = True
commands = black --check mail_editor tests
commands = black --check mail_editor tests testapp

[testenv:flake8]
extras = tests
Expand Down

0 comments on commit faab3a7

Please sign in to comment.