From f425673953301630fdfc20528ec1bc51140aad6f Mon Sep 17 00:00:00 2001 From: yann Date: Wed, 10 Sep 2025 12:33:33 +0200 Subject: [PATCH] fix linting --- tests/conftest.py | 46 ++++++++++++------------ tests/unit/oc_lettings_site/test_urls.py | 2 +- tests/unit/oc_lettings_site/test_view.py | 2 +- tests/unit/profiles/test_models.py | 5 ++- tests/unit/profiles/test_urls.py | 2 +- tests/unit/profiles/test_views.py | 2 +- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 6b006cb..cde3221 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,20 +12,20 @@ def sample_address(): :return: tuple of Address """ address1 = Address.objects.create( - number = 22, - street = "Quality Street", - city = "New-York", - state = "New-York", - zip_code = 10010, - country_iso_code = "US" + number=22, + street="Quality Street", + city="New-York", + state="New-York", + zip_code=10010, + country_iso_code="US" ) address2 = Address.objects.create( - number = 18, - street = "Rue Cocotte", - city = "Paris", - state = "Ile-de-France", - zip_code = 75000, - country_iso_code = "FR" + number=18, + street="Rue Cocotte", + city="Paris", + state="Ile-de-France", + zip_code=75000, + country_iso_code="FR" ) return address1, address2 @@ -38,12 +38,12 @@ def sample_letting(sample_address): :return: tuple of Lettings """ letting = Letting.objects.create( - title = "Pretty thing", - address = sample_address[0], + title="Pretty thing", + address=sample_address[0], ) letting2 = Letting.objects.create( - title = "Ugly thing", - address = sample_address[1], + title="Ugly thing", + address=sample_address[1], ) return letting, letting2 @@ -57,16 +57,16 @@ def sample_profile(): :return: tuple of Profiles """ user = User.objects.create( - username = 'TestUser', - password = 'password', + username='TestUser', + password='password', ) user2 = User.objects.create( - username = 'TestUser2', - password = 'password2', + username='TestUser2', + password='password2', ) user3 = User.objects.create( - username = 'TestUser3', - password = 'password2', + username='TestUser3', + password='password2', ) profile = Profile.objects.create( user=user, @@ -80,4 +80,4 @@ def sample_profile(): user=user3, favorite_city="Rennes", ) - return profile, profile2, profile3 \ No newline at end of file + return profile, profile2, profile3 diff --git a/tests/unit/oc_lettings_site/test_urls.py b/tests/unit/oc_lettings_site/test_urls.py index 074ff6f..a877830 100644 --- a/tests/unit/oc_lettings_site/test_urls.py +++ b/tests/unit/oc_lettings_site/test_urls.py @@ -15,4 +15,4 @@ def test_home_url(): """ test the home url """ url = reverse('index') assert resolve(url).view_name == 'index' - assert resolve(url).func, index() \ No newline at end of file + assert resolve(url).func, index() diff --git a/tests/unit/oc_lettings_site/test_view.py b/tests/unit/oc_lettings_site/test_view.py index 0178d0d..4570c61 100644 --- a/tests/unit/oc_lettings_site/test_view.py +++ b/tests/unit/oc_lettings_site/test_view.py @@ -7,4 +7,4 @@ def test_view_should_reply_title_on_home(): c = Client() url = reverse('index') response = c.get(url) - assert "Welcome to Holiday Homes" in response.content.decode() \ No newline at end of file + assert "Welcome to Holiday Homes" in response.content.decode() diff --git a/tests/unit/profiles/test_models.py b/tests/unit/profiles/test_models.py index a8a1cb3..d4e33ae 100644 --- a/tests/unit/profiles/test_models.py +++ b/tests/unit/profiles/test_models.py @@ -6,12 +6,11 @@ from profiles.models import Profile @pytest.mark.django_db def test_str_profile(): user = User.objects.create( - username = 'TestUser', - password = 'password', + username='TestUser', + password='password', ) profile = Profile.objects.create( user=user, favorite_city="Paris", - ) assert str(profile) == "TestUser" diff --git a/tests/unit/profiles/test_urls.py b/tests/unit/profiles/test_urls.py index 4ad1044..e3a3974 100644 --- a/tests/unit/profiles/test_urls.py +++ b/tests/unit/profiles/test_urls.py @@ -11,6 +11,7 @@ def test_should_get_200_on_profile_index(): response = c.get(url) assert response.status_code == 200 + @pytest.mark.django_db def test_should_get_200_on_profile_detail(sample_profile): """ test the server's response on a profile detail page """ @@ -18,4 +19,3 @@ def test_should_get_200_on_profile_detail(sample_profile): url = reverse('profile', kwargs={'username': "TestUser"}) response = c.get(url) assert response.status_code == 200 - diff --git a/tests/unit/profiles/test_views.py b/tests/unit/profiles/test_views.py index ac66f92..f803b25 100644 --- a/tests/unit/profiles/test_views.py +++ b/tests/unit/profiles/test_views.py @@ -3,6 +3,7 @@ from django.test import Client from django.urls import reverse from bs4 import BeautifulSoup + @pytest.mark.django_db def test_view_should_display_right_len_list(sample_profile): """ @@ -15,4 +16,3 @@ def test_view_should_display_right_len_list(sample_profile): soup = BeautifulSoup(response.content, 'html.parser') li_tags = soup.find_all('li') assert len(li_tags) == 3 -