diff --git a/manifest.json b/manifest.json index 299e7e7..196ceea 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Web based FritzBox management using Python/Django." }, - "version": "0.0.2.rc0~ynh1", + "version": "0.0.2.rc1~ynh1", "url": "https://github.com/jedie/django-fritzconnection", "upstream": { "license": "GPL-3.0", diff --git a/pyproject.toml b/pyproject.toml index 4fc79a1..d609abb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-fritzconnection_ynh" -version = "0.0.2.rc0~ynh1" +version = "0.0.2.rc1~ynh1" description = "Test django-fritzconnection_ynh via local_test.py" authors = ["JensDiemer "] license = "GPL" @@ -39,7 +39,7 @@ build-backend = "poetry.core.masonry.api" [tool.darker] src = ['.'] revision = "origin/master..." -line_length = 120 +line_length = 100 verbose = true skip_string_normalization = true diff = false @@ -53,14 +53,14 @@ log_level = "INFO" [tool.flynt] -line_length = 120 +line_length = 100 [tool.isort] # https://pycqa.github.io/isort/docs/configuration/config_files/#pyprojecttoml-preferred-format atomic=true profile='black' -line_length=120 +line_length=100 skip_glob=["*/htmlcov/*","*/migrations/*"] known_first_party=["djfritz","djfritz_project","djfritz_tests"] lines_after_imports=2 diff --git a/tests/test_django_project.py b/tests/test_django_project.py index ceda7d3..850008c 100644 --- a/tests/test_django_project.py +++ b/tests/test_django_project.py @@ -1,6 +1,5 @@ from pathlib import Path -from axes.models import AccessLog from bx_django_utils.test_utils.html_assertion import HtmlAssertionMixin from django.conf import LazySettings, settings from django.contrib.auth.models import User @@ -11,7 +10,7 @@ from django.urls.base import reverse from django_yunohost_integration.test_utils import generate_basic_auth from django_yunohost_integration.views import request_media_debug_view -import inventory +import djfritz @override_settings(DEBUG=False) @@ -40,18 +39,12 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): assert settings.ROOT_URLCONF == 'urls' def test_urls(self): - assert reverse('admin:index') == '/app_path/' + assert reverse('admin:index') == '/app_path/admin/' # The django_yunohost_integration debug view should not be available: with self.assertRaises(NoReverseMatch): reverse(request_media_debug_view) - # Serve user uploads via django_tools.serve_media_app: - assert settings.MEDIA_URL == '/app_path/media/' - assert reverse('serve_media_app:serve-media', kwargs={'user_token': 'token', 'path': 'foo/bar/'}) == ( - '/app_path/media/token/foo/bar/' - ) - def test_auth(self): # SecurityMiddleware should redirects all non-HTTPS requests to HTTPS: assert settings.SECURE_SSL_REDIRECT is True @@ -64,7 +57,16 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): ) response = self.client.get('/app_path/', secure=True) - self.assertRedirects(response, expected_url='/app_path/login/?next=/app_path/', fetch_redirect_response=False) + self.assertRedirects( + response, expected_url='/app_path/admin/', fetch_redirect_response=False + ) + + response = self.client.get('/app_path/admin/', secure=True) + self.assertRedirects( + response, + expected_url='/app_path/admin/login/?next=/app_path/admin/', + fetch_redirect_response=False, + ) @override_settings(SECURE_SSL_REDIRECT=False) def test_create_unknown_user(self): @@ -73,7 +75,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): self.client.cookies['SSOwAuthUser'] = 'test' response = self.client.get( - path='/app_path/', + path='/app_path/admin/', HTTP_REMOTE_USER='test', HTTP_AUTH_USER='test', HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz', @@ -90,7 +92,10 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): self.assert_html_parts( response, parts=( - f'Site administration | django-fritzconnection v{inventory.__version__}', + ( + 'Site administration | django-fritzconnection' + f' v{djfritz.__version__}' + ), 'test', ), ) @@ -98,12 +103,11 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): @override_settings(SECURE_SSL_REDIRECT=False) def test_wrong_auth_user(self): assert User.objects.count() == 0 - assert AccessLog.objects.count() == 0 self.client.cookies['SSOwAuthUser'] = 'test' response = self.client.get( - path='/app_path/', + path='/app_path/admin/', HTTP_REMOTE_USER='test', HTTP_AUTH_USER='foobar', # <<< wrong user name HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz', @@ -116,19 +120,16 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): assert user.is_staff is True # Set by: django_yunohost_integration assert user.is_superuser is False - assert AccessLog.objects.count() == 1 - assert response.status_code == 403 # Forbidden @override_settings(SECURE_SSL_REDIRECT=False) def test_wrong_cookie(self): assert User.objects.count() == 0 - assert AccessLog.objects.count() == 0 self.client.cookies['SSOwAuthUser'] = 'foobar' # <<< wrong user name response = self.client.get( - path='/app_path/', + path='/app_path/admin/', HTTP_REMOTE_USER='test', HTTP_AUTH_USER='test', HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz', @@ -141,8 +142,6 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): assert user.is_staff is True # Set by: django_yunohost_integration assert user.is_superuser is False - assert AccessLog.objects.count() == 1 - assert response.status_code == 403 # Forbidden @override_settings(SECURE_SSL_REDIRECT=False) @@ -152,10 +151,12 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): self.client.cookies['SSOwAuthUser'] = 'test' response = self.client.get( - path='/app_path/', + path='/app_path/admin/', HTTP_REMOTE_USER='test', HTTP_AUTH_USER='test', - HTTP_AUTHORIZATION=generate_basic_auth(username='foobar', password='test123'), # <<< wrong user name + HTTP_AUTHORIZATION=generate_basic_auth( + username='foobar', password='test123' + ), # <<< wrong user name ) assert User.objects.count() == 1 @@ -165,6 +166,4 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): assert user.is_staff is True # Set by: django_yunohost_integration assert user.is_superuser is False - assert AccessLog.objects.count() == 1 - assert response.status_code == 403 # Forbidden diff --git a/tests/test_project_setup.py b/tests/test_project_setup.py index e48f9c5..479476f 100644 --- a/tests/test_project_setup.py +++ b/tests/test_project_setup.py @@ -6,7 +6,7 @@ from pathlib import Path from bx_py_utils.path import assert_is_file -import inventory +import djfritz PACKAGE_ROOT = Path(__file__).parent.parent @@ -21,10 +21,14 @@ def assert_file_contains_string(file_path, string): def test_version(): - version = inventory.__version__ + version = djfritz.__version__ - assert_file_contains_string(file_path=Path(PACKAGE_ROOT, 'pyproject.toml'), string=f'version = "{version}~ynh') - assert_file_contains_string(file_path=Path(PACKAGE_ROOT, 'manifest.json'), string=f'"version": "{version}~ynh') + assert_file_contains_string( + file_path=Path(PACKAGE_ROOT, 'pyproject.toml'), string=f'version = "{version}~ynh' + ) + assert_file_contains_string( + file_path=Path(PACKAGE_ROOT, 'manifest.json'), string=f'"version": "{version}~ynh' + ) def poetry_check_output(*args): @@ -57,7 +61,10 @@ def test_requirements_txt(): diff = '\n'.join( difflib.unified_diff( - current_content.splitlines(), output.splitlines(), fromfile=str(requirements_txt), tofile='FRESH EXPORT' + current_content.splitlines(), + output.splitlines(), + fromfile=str(requirements_txt), + tofile='FRESH EXPORT', ) ) print(diff)