-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3.
- Loading branch information
Showing
9 changed files
with
119 additions
and
98 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Python application | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install uv | ||
uv pip install --system -r requirements.txt | ||
- name: Test with the Django testsuite | ||
env: | ||
ALLOWED_HOSTS: '["*"]' | ||
DATABASE_URL: "sqlite://traduire.db" | ||
DEBUG: "True" | ||
LIVE: "False" | ||
NAMESPACE: "test" | ||
SECRET_KEY: "unsafe" | ||
TESTING: "True" | ||
|
||
run: | | ||
python manage.py test -v2 |
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 |
---|---|---|
|
@@ -25,3 +25,4 @@ app/static/app/dist | |
/*.sql | ||
/.vscode | ||
.tox | ||
.coverage |
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from authlib.little_auth.models import User | ||
from django.test import TestCase | ||
|
||
from projects.models import Project | ||
|
||
|
||
class ProjectsTest(TestCase): | ||
def test_smoke(self): | ||
user = User.objects.create_superuser("admin@example.com", "admin") | ||
self.client.force_login(user) | ||
|
||
p = Project.objects.create(name="test", slug="test") | ||
c = p.catalogs.create( | ||
language_code="fr", | ||
domain="djangojs", | ||
pofile="""\ | ||
#: conf/strings.js frontend/intro/intro.js frontend/people/person.js | ||
msgid "Continue" | ||
msgstr "Continuer" | ||
#: conf/strings.js | ||
msgid "Copied code!" | ||
msgstr "Code copié !" | ||
#: fmw/dashboard/classes/forms.py | ||
#, python-format | ||
msgid "Successfully reset the password of %(count)s student." | ||
msgid_plural "Successfully reset passwords of %(count)s students." | ||
msgstr[0] "Réinitialisation du mot de passe de %(count)s élève." | ||
msgstr[1] "Réinitialisation des mots de passe de %(count)s élèves ." | ||
""", | ||
) | ||
|
||
r = self.client.get("/", headers={"accept-language": "en"}) | ||
|
||
self.assertContains(r, '<a href="/project/test/">test</a>') | ||
|
||
r = self.client.get(p.get_absolute_url(), headers={"accept-language": "en"}) | ||
self.assertContains(r, p.token) | ||
self.assertContains( | ||
r, | ||
'<a href="/project/test/catalog/fr/djangojs/">French, djangojs (100%)</a>', | ||
) | ||
|
||
r = self.client.get(c.get_absolute_url(), headers={"accept-language": "en"}) | ||
self.assertContains( | ||
r, | ||
'<input type="hidden" name="msgid_1" value="Copied code!" id="id_msgid_1">', | ||
) | ||
|
||
# API test | ||
r = self.client.get("/api/pofile/fr/djangojs/") | ||
self.assertEqual(r.status_code, 403) | ||
|
||
r = self.client.get( | ||
"/api/pofile/fr/djangojs/", headers={"x-project-token": p.token} | ||
) | ||
self.assertEqual(r.content.decode("utf-8"), c.pofile) | ||
|
||
r = self.client.get( | ||
"/api/pofile/de/djangojs/", headers={"x-project-token": p.token} | ||
) | ||
self.assertEqual(r.status_code, 404) | ||
|
||
# print(r, r.content.decode("utf-8")) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
set -ex | ||
.venv/bin/coverage erase | ||
.venv/bin/python -Wall .venv/bin/coverage run ./manage.py test -v 2 --keepdb $* | ||
|
||
if [ $# -eq 0 ]; then | ||
.venv/bin/coverage report | ||
fi |