Compare commits

...

9 Commits

Author SHA1 Message Date
d8068894bf build ok gunicorn+nginx 2025-09-15 11:12:08 +02:00
8095aa76ef try poetry-plugin-export 2025-09-15 11:07:49 +02:00
381f83af7e move key in .env 2025-09-15 10:51:00 +02:00
a43f42b4e4 add endline 2025-09-12 15:33:13 +02:00
3359cd63ce remove old print 2025-09-12 15:32:16 +02:00
f425673953 fix linting 2025-09-10 12:33:33 +02:00
f5c04f9d58 fix logging and exception 2025-09-10 12:32:36 +02:00
f6e8758541 unused, clean archi 2025-09-10 12:31:38 +02:00
7aeb92913c sentry logging on unknown querystring 2025-09-10 10:45:42 +02:00
16 changed files with 283 additions and 78 deletions

32
Dockerfile Normal file
View File

@@ -0,0 +1,32 @@
FROM python:3.11-slim
RUN apt update && apt install -y nginx
RUN pip install poetry
WORKDIR /OCLettings2
COPY pyproject.toml poetry.lock ./
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
RUN poetry config virtualenvs.create false && \
poetry install --no-interaction --no-ansi --no-root && \
poetry add gunicorn
COPY . .
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
RUN rm -rf /var/www/html* && \
mkdir -p /run/nginx
RUN poetry run python manage.py collectstatic --noinput
EXPOSE 80
CMD service nginx start && \
poetry run gunicorn --bind 127.0.0.1:8000 --env DJANGO_SETTINGS_MODULE=oc_lettings_site.settings oc_lettings_site.wsgi
#CMD ["poetry", "run", "gunicorn", "--bind", "0.0.0.0:8080", "--env", "DJANGO_SETTINGS_MODULE=oc_lettings_site.settings", "oc_lettings_site.wsgi"]

View File

@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -1,5 +1,9 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
from lettings.models import Letting
import logging
logger = logging.getLogger(__name__)
def index(request):
@@ -19,9 +23,13 @@ def letting(request, letting_id):
:param request: None
:return: render and display template HTML
"""
try:
letting = Letting.objects.get(id=letting_id)
context = {
'title': letting.title,
'address': letting.address,
}
return render(request, 'lettings/letting.html', context)
except ValueError:
logger.error(f"letting id : {letting_id} not found")
return redirect('lettings_index')

22
nginx/nginx.conf Normal file
View File

@@ -0,0 +1,22 @@
upstream django {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name localhost;
location /static/ {
alias /OCLettings2/staticfiles/;
expires 30d;
}
location / {
proxy_pass http://django;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

View File

@@ -1,6 +1,10 @@
import os
import sentry_sdk
from pathlib import Path
from dotenv import load_dotenv, dotenv_values
load_dotenv()
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -10,7 +14,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'fp$9^593hsriajg$_%=5trot9g!1qa@ew(o-1#@=&4%=hp46(s'
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
@@ -118,3 +122,10 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / "static"]
# Config Sentry
sentry_sdk.init(
dsn=os.getenv("SENTRY_URL"),
send_default_pii=True,
enable_logs=True,
)

View File

@@ -1,2 +0,0 @@
def test_dummy():
assert 1

186
poetry.lock generated
View File

@@ -84,6 +84,18 @@ files = [
[package.dependencies]
beautifulsoup4 = "*"
[[package]]
name = "certifi"
version = "2025.8.3"
description = "Python package for providing Mozilla's CA Bundle."
optional = false
python-versions = ">=3.7"
groups = ["main"]
files = [
{file = "certifi-2025.8.3-py3-none-any.whl", hash = "sha256:f6c12493cfb1b06ba2ff328595af9350c65d6644968e5d3a2ffd78699af217a5"},
{file = "certifi-2025.8.3.tar.gz", hash = "sha256:e564105f78ded564e3ae7c923924435e1daa7463faeab5bb932bc53ffae63407"},
]
[[package]]
name = "colorama"
version = "0.4.5"
@@ -233,6 +245,20 @@ files = [
{file = "django-pytest-0.2.0.tar.gz", hash = "sha256:de21f20f9e7eb941529d75078b18192506a9f6d4ae80f86fbe2f3bcac8e09d71"},
]
[[package]]
name = "dotenv"
version = "0.9.9"
description = "Deprecated package"
optional = false
python-versions = "*"
groups = ["main"]
files = [
{file = "dotenv-0.9.9-py2.py3-none-any.whl", hash = "sha256:29cf74a087b31dafdb5a446b6d7e11cbce8ed2741540e2339c69fbef92c94ce9"},
]
[package.dependencies]
python-dotenv = "*"
[[package]]
name = "entrypoints"
version = "0.3"
@@ -289,19 +315,16 @@ files = [
[[package]]
name = "packaging"
version = "21.3"
version = "25.0"
description = "Core utilities for Python packages"
optional = false
python-versions = ">=3.6"
python-versions = ">=3.8"
groups = ["main"]
files = [
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
{file = "packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484"},
{file = "packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f"},
]
[package.dependencies]
pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
[[package]]
name = "pluggy"
version = "1.6.0"
@@ -354,21 +377,6 @@ files = [
{file = "pyflakes-2.1.1.tar.gz", hash = "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2"},
]
[[package]]
name = "pyparsing"
version = "3.0.7"
description = "Python parsing module"
optional = false
python-versions = ">=3.6"
groups = ["main"]
files = [
{file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"},
{file = "pyparsing-3.0.7.tar.gz", hash = "sha256:18ee9022775d270c55187733956460083db60b37d0d0fb357445f3094eed3eea"},
]
[package.extras]
diagrams = ["jinja2", "railroad-diagrams"]
[[package]]
name = "pytest"
version = "7.0.1"
@@ -433,6 +441,21 @@ pytest = ">=3.6"
docs = ["sphinx", "sphinx-rtd-theme"]
testing = ["Django", "django-configurations (>=2.0)", "six"]
[[package]]
name = "python-dotenv"
version = "1.1.1"
description = "Read key-value pairs from a .env file and set them as environment variables"
optional = false
python-versions = ">=3.9"
groups = ["main"]
files = [
{file = "python_dotenv-1.1.1-py3-none-any.whl", hash = "sha256:31f23644fe2602f88ff55e1f5c79ba497e01224ee7737937930c448e4d0e24dc"},
{file = "python_dotenv-1.1.1.tar.gz", hash = "sha256:a8a6399716257f45be6a007360200409fce5cda2661e3dec71d23dc15f6189ab"},
]
[package.extras]
cli = ["click (>=5.0)"]
[[package]]
name = "pytz"
version = "2025.2"
@@ -445,6 +468,65 @@ files = [
{file = "pytz-2025.2.tar.gz", hash = "sha256:360b9e3dbb49a209c21ad61809c7fb453643e048b38924c765813546746e81c3"},
]
[[package]]
name = "sentry-sdk"
version = "2.37.1"
description = "Python client for Sentry (https://sentry.io)"
optional = false
python-versions = ">=3.6"
groups = ["main"]
files = [
{file = "sentry_sdk-2.37.1-py2.py3-none-any.whl", hash = "sha256:baaaea6608ed3a639766a69ded06b254b106d32ad9d180bdbe58f3db9364592b"},
{file = "sentry_sdk-2.37.1.tar.gz", hash = "sha256:531751da91aa62a909b42a7be155b41f6bb0de9df6ae98441d23b95de2f98475"},
]
[package.dependencies]
certifi = "*"
django = {version = ">=1.8", optional = true, markers = "extra == \"django\""}
urllib3 = ">=1.26.11"
[package.extras]
aiohttp = ["aiohttp (>=3.5)"]
anthropic = ["anthropic (>=0.16)"]
arq = ["arq (>=0.23)"]
asyncpg = ["asyncpg (>=0.23)"]
beam = ["apache-beam (>=2.12)"]
bottle = ["bottle (>=0.12.13)"]
celery = ["celery (>=3)"]
celery-redbeat = ["celery-redbeat (>=2)"]
chalice = ["chalice (>=1.16.0)"]
clickhouse-driver = ["clickhouse-driver (>=0.2.0)"]
django = ["django (>=1.8)"]
falcon = ["falcon (>=1.4)"]
fastapi = ["fastapi (>=0.79.0)"]
flask = ["blinker (>=1.1)", "flask (>=0.11)", "markupsafe"]
grpcio = ["grpcio (>=1.21.1)", "protobuf (>=3.8.0)"]
http2 = ["httpcore[http2] (==1.*)"]
httpx = ["httpx (>=0.16.0)"]
huey = ["huey (>=2)"]
huggingface-hub = ["huggingface_hub (>=0.22)"]
langchain = ["langchain (>=0.0.210)"]
langgraph = ["langgraph (>=0.6.6)"]
launchdarkly = ["launchdarkly-server-sdk (>=9.8.0)"]
litestar = ["litestar (>=2.0.0)"]
loguru = ["loguru (>=0.5)"]
openai = ["openai (>=1.0.0)", "tiktoken (>=0.3.0)"]
openfeature = ["openfeature-sdk (>=0.7.1)"]
opentelemetry = ["opentelemetry-distro (>=0.35b0)"]
opentelemetry-experimental = ["opentelemetry-distro"]
pure-eval = ["asttokens", "executing", "pure_eval"]
pymongo = ["pymongo (>=3.1)"]
pyspark = ["pyspark (>=2.4.4)"]
quart = ["blinker (>=1.1)", "quart (>=0.16.1)"]
rq = ["rq (>=0.6)"]
sanic = ["sanic (>=0.8)"]
sqlalchemy = ["sqlalchemy (>=1.2)"]
starlette = ["starlette (>=0.19.1)"]
starlite = ["starlite (>=1.48)"]
statsig = ["statsig (>=0.55.3)"]
tornado = ["tornado (>=6)"]
unleash = ["UnleashClient (>=6.0.1)"]
[[package]]
name = "six"
version = "1.17.0"
@@ -488,14 +570,44 @@ test = ["pytest", "pytest-cov"]
[[package]]
name = "tomli"
version = "1.2.3"
version = "2.2.1"
description = "A lil' TOML parser"
optional = false
python-versions = ">=3.6"
python-versions = ">=3.8"
groups = ["main"]
files = [
{file = "tomli-1.2.3-py3-none-any.whl", hash = "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c"},
{file = "tomli-1.2.3.tar.gz", hash = "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f"},
{file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"},
{file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"},
{file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a"},
{file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee"},
{file = "tomli-2.2.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e"},
{file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4"},
{file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106"},
{file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8"},
{file = "tomli-2.2.1-cp311-cp311-win32.whl", hash = "sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff"},
{file = "tomli-2.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b"},
{file = "tomli-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea"},
{file = "tomli-2.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8"},
{file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192"},
{file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222"},
{file = "tomli-2.2.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77"},
{file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6"},
{file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd"},
{file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e"},
{file = "tomli-2.2.1-cp312-cp312-win32.whl", hash = "sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98"},
{file = "tomli-2.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4"},
{file = "tomli-2.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7"},
{file = "tomli-2.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c"},
{file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13"},
{file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281"},
{file = "tomli-2.2.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272"},
{file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140"},
{file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2"},
{file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744"},
{file = "tomli-2.2.1-cp313-cp313-win32.whl", hash = "sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec"},
{file = "tomli-2.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69"},
{file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"},
{file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"},
]
[[package]]
@@ -510,7 +622,25 @@ files = [
{file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"},
]
[[package]]
name = "urllib3"
version = "2.5.0"
description = "HTTP library with thread-safe connection pooling, file post, and more."
optional = false
python-versions = ">=3.9"
groups = ["main"]
files = [
{file = "urllib3-2.5.0-py3-none-any.whl", hash = "sha256:e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc"},
{file = "urllib3-2.5.0.tar.gz", hash = "sha256:3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760"},
]
[package.extras]
brotli = ["brotli (>=1.0.9) ; platform_python_implementation == \"CPython\"", "brotlicffi (>=0.8.0) ; platform_python_implementation != \"CPython\""]
h2 = ["h2 (>=4,<5)"]
socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"]
zstd = ["zstandard (>=0.18.0)"]
[metadata]
lock-version = "2.1"
python-versions = ">=3.9"
content-hash = "e34e8fea6a43e8fe268a2b369103060c957c2e2da85aa8b0887299219efe5735"
python-versions = ">=3.9, <4.0"
content-hash = "ff2e5437fe8f89479484f9df2dea16b0893c8dcee4f7641cf7af85becf2d1379"

View File

@@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -1,5 +1,9 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
from profiles.models import Profile
import logging
logger = logging.getLogger(__name__)
def index(request):
@@ -19,6 +23,10 @@ def profile(request, username):
:param request: None
:return: render and display template as HTML
"""
try:
profile = Profile.objects.get(user__username=username)
context = {'profile': profile}
return render(request, 'profiles/profile.html', context)
except (ValueError, Profile.DoesNotExist):
logger.error(f"Username : {username} doesn't exist")
return redirect('profiles_index')

View File

@@ -6,7 +6,7 @@ authors = [
{name = "Your Name",email = "you@example.com"}
]
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.9, <4.0"
dependencies = [
"django (==3.0)",
"flake8 (==3.7.0)",
@@ -15,6 +15,8 @@ dependencies = [
"six (>=1.17.0,<2.0.0)",
"pytest-cov (>=6.3.0,<7.0.0)",
"bs4 (>=0.0.2,<0.0.3)",
"sentry-sdk[django] (>=2.37.1,<3.0.0)",
"dotenv (>=0.9.9,<0.10.0)",
]

View File

@@ -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,

View File

@@ -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"

View File

@@ -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 """

View File

@@ -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