Skip to content

Commit

Permalink
Switch to a src/ layout
Browse files Browse the repository at this point in the history
src/wagtail_localize_git
tests/
  • Loading branch information
zerolab committed Jan 17, 2024
1 parent 1ebc867 commit 54e69f5
Show file tree
Hide file tree
Showing 33 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
- run: python -Im pip install --user ruff

- name: Run ruff
working-directory: .
working-directory: ./src
run: ruff --output-format=github wagtail_localize_git
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ tox
```

or, you can run them for a specific environment `tox -e py3.11-django4.2-wagtail5.2` or specific test
`tox -e py3.11-django4.2-wagtail5.2-sqlite wagtail_localize_git.tests.test_git.TestRepository`
`tox -e py3.11-django4.2-wagtail5.2-sqlite -- tests.test_git.TestRepository`

To run the test app interactively, use `tox -e interactive`, visit `http://127.0.0.1:8020/admin/` and log in with `admin`/`changeme`.
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ name = "wagtail_localize_git"

[tool.flit.sdist]
exclude = [
"wagtail_localize_git/tests",
"wagtail_localize_git/test",
".*",
"*.db",
"*.json",
"*.ini",
"*.yaml",
"tests",
"CHANGELOG.md",
"testmanage.py",
]
Expand Down Expand Up @@ -92,6 +91,6 @@ ignore = ["E501"]
fixable = ["C4", "E", "F", "I", "UP"]

[tool.ruff.isort]
known-first-party = ["wagtail_localize_git"]
known-first-party = ["src", "wagtail_localize_git"]
lines-between-types = 1
lines-after-imports = 2
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion testmanage.py → tests/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from django.core.management import execute_from_command_line


os.environ["DJANGO_SETTINGS_MODULE"] = "wagtail_localize_git.test.settings"
os.environ["DJANGO_SETTINGS_MODULE"] = "testapp.settings"
sys.path.append("tests")


def make_parser():
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.core.exceptions import ValidationError
from django.test import TestCase
from django.utils import timezone
from testapp.models import TestPage
from wagtail.models import Locale, Page
from wagtail_localize.models import (
MissingRelatedObjectError,
Expand All @@ -16,7 +17,6 @@

from wagtail_localize_git.importer import Importer
from wagtail_localize_git.models import Resource, SyncLog
from wagtail_localize_git.test.models import TestPage


def create_test_page(**kwargs):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from django.test import TestCase
from testapp.models import TestPage, TestSnippet
from wagtail.documents.models import Document
from wagtail.images.models import Image
from wagtail.images.tests.utils import get_test_image_file
from wagtail.models import Page, Site
from wagtail_localize.models import TranslationSource

from wagtail_localize_git.models import Resource
from wagtail_localize_git.test.models import TestPage, TestSnippet


def create_test_page(**kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import pygit2

from django.test import TestCase, override_settings
from testapp.models import TestPage
from wagtail.models import Locale, Page
from wagtail_localize.models import StringTranslation, Translation, TranslationSource

from wagtail_localize_git.models import Resource, SyncLog
from wagtail_localize_git.sync import SyncPushError, _pull, _push, get_sync_manager
from wagtail_localize_git.test.models import TestPage

from .utils import GitRepositoryUtils

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from django.contrib.auth.models import Group
from django.test import TestCase
from django.urls import reverse
from testapp.models import TestPage
from wagtail.models import Locale, Page
from wagtail.test.utils import WagtailTestUtils
from wagtail_localize.models import Translation, TranslationSource

from wagtail_localize_git.models import Resource, SyncLog, SyncLogResource
from wagtail_localize_git.test.models import TestPage


def create_test_page(**kwargs):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class WagtailLocalizeGitTestAppConfig(AppConfig):
label = "wagtail_localize_git_test"
name = "wagtail_localize_git.test"
name = "testapp"
verbose_name = "Localize Git tests"
default_auto_field = "django.db.models.AutoField"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,16 @@

INSTALLED_APPS = [
"wagtail_localize_git",
"wagtail_localize_git.test",
"testapp",
"wagtail_localize",
"wagtail.contrib.search_promotions",
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.embeds",
"wagtail.users",
"wagtail.snippets",
"wagtail.documents",
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail.api.v2",
"wagtail.contrib.modeladmin",
"wagtail.contrib.routable_page",
"wagtail.contrib.styleguide",
"wagtail.sites",
"wagtail",
"taggit",
"rest_framework",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
Expand All @@ -75,7 +65,7 @@
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
]

ROOT_URLCONF = "wagtail_localize_git.test.urls"
ROOT_URLCONF = "testapp.urls"

TEMPLATES = [
{
Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 9 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pass_env =
NO_COLOR

setenv =
PYTHONPATH = {toxinidir}
PYTHONPATH = {toxinidir}/tests:{toxinidir}
PYTHONDEVMODE = 1

deps =
Expand All @@ -47,8 +47,10 @@ deps =
.[testing]

install_command = python -Im pip install -U --pre {opts} {packages}
commands_pre =
python -I {toxinidir}/tests/manage.py migrate
commands =
python -m coverage run testmanage.py test --deprecation all {posargs: -v 2}
python -m coverage run {toxinidir}/tests/manage.py test --deprecation all {posargs: -v 2}

[testenv:coverage-report]
commands =
Expand All @@ -60,13 +62,13 @@ description = An interactive environment for local testing purposes
basepython = python3.11

commands_pre =
python {toxinidir}/testmanage.py makemigrations
python {toxinidir}/testmanage.py migrate
python {toxinidir}/testmanage.py shell -c "from django.contrib.auth.models import User;(not User.objects.filter(username='admin').exists()) and User.objects.create_superuser('admin', 'super@example.com', 'changeme')"
python {toxinidir}/testmanage.py createcachetable
python {toxinidir}/tests/manage.py makemigrations
python {toxinidir}/tests/manage.py migrate
python {toxinidir}/tests/manage.py shell -c "from django.contrib.auth.models import User;(not User.objects.filter(username='admin').exists()) and User.objects.create_superuser('admin', 'super@example.com', 'changeme')"
python {toxinidir}/tests/manage.py createcachetable

commands =
{posargs:python testmanage.py runserver 0.0.0.0:8020}
{posargs:python -Im {toxinidir}/tests/manage.py runserver 0.0.0.0:8020}

setenv =
INTERACTIVE = 1
Expand Down

0 comments on commit 54e69f5

Please sign in to comment.