add docstrings
This commit is contained in:
@@ -4,7 +4,7 @@ from django.core.validators import MaxValueValidator, MinLengthValidator
|
|||||||
|
|
||||||
class Address(models.Model):
|
class Address(models.Model):
|
||||||
"""
|
"""
|
||||||
Details of the physical location of a property
|
Model of details for a physical location of a property
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -29,7 +29,7 @@ class Address(models.Model):
|
|||||||
|
|
||||||
class Letting(models.Model):
|
class Letting(models.Model):
|
||||||
"""
|
"""
|
||||||
Announce for a property to rent
|
Model of an announce for a property to rent
|
||||||
"""
|
"""
|
||||||
title = models.CharField(max_length=256)
|
title = models.CharField(max_length=256)
|
||||||
address = models.OneToOneField(Address, on_delete=models.CASCADE)
|
address = models.OneToOneField(Address, on_delete=models.CASCADE)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from django.contrib.auth.models import User
|
|||||||
|
|
||||||
class Profile(models.Model):
|
class Profile(models.Model):
|
||||||
"""
|
"""
|
||||||
Defines a service user
|
Model of a user of the service
|
||||||
"""
|
"""
|
||||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||||
favorite_city = models.CharField(max_length=64, blank=True)
|
favorite_city = models.CharField(max_length=64, blank=True)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from django.test import Client
|
|||||||
|
|
||||||
|
|
||||||
def test_server_should_answer_200():
|
def test_server_should_answer_200():
|
||||||
""" test the server's response """
|
""" test the server's response on home """
|
||||||
c = Client()
|
c = Client()
|
||||||
url = reverse('index')
|
url = reverse('index')
|
||||||
response = c.get(url)
|
response = c.get(url)
|
||||||
@@ -12,7 +12,7 @@ def test_server_should_answer_200():
|
|||||||
|
|
||||||
|
|
||||||
def test_home_url():
|
def test_home_url():
|
||||||
""" test the home page"""
|
""" test the home url """
|
||||||
url = reverse('index')
|
url = reverse('index')
|
||||||
assert resolve(url).view_name == 'index'
|
assert resolve(url).view_name == 'index'
|
||||||
assert resolve(url).func, index()
|
assert resolve(url).func, index()
|
||||||
@@ -5,7 +5,7 @@ from django.test import Client
|
|||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_should_get_200_on_profile_index():
|
def test_should_get_200_on_profile_index():
|
||||||
""" test the server's response """
|
""" test the server's response on profile index page """
|
||||||
c = Client()
|
c = Client()
|
||||||
url = reverse('profiles_index')
|
url = reverse('profiles_index')
|
||||||
response = c.get(url)
|
response = c.get(url)
|
||||||
@@ -13,6 +13,7 @@ def test_should_get_200_on_profile_index():
|
|||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_should_get_200_on_profile_detail(sample_profile):
|
def test_should_get_200_on_profile_detail(sample_profile):
|
||||||
|
""" test the server's response on a profile detail page """
|
||||||
c = Client()
|
c = Client()
|
||||||
url = reverse('profile', kwargs={'username': "TestUser"})
|
url = reverse('profile', kwargs={'username': "TestUser"})
|
||||||
response = c.get(url)
|
response = c.get(url)
|
||||||
|
|||||||
@@ -5,9 +5,14 @@ from bs4 import BeautifulSoup
|
|||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_view_should_display_right_len_list(sample_profile):
|
def test_view_should_display_right_len_list(sample_profile):
|
||||||
|
"""
|
||||||
|
test that html page displays the right amount of objects
|
||||||
|
created by fixture
|
||||||
|
"""
|
||||||
c = Client()
|
c = Client()
|
||||||
url = reverse('profiles_index')
|
url = reverse('profiles_index')
|
||||||
response = c.get(url)
|
response = c.get(url)
|
||||||
soup = BeautifulSoup(response.content, 'html.parser')
|
soup = BeautifulSoup(response.content, 'html.parser')
|
||||||
li_tags = soup.find_all('li')
|
li_tags = soup.find_all('li')
|
||||||
assert len(li_tags) == 3
|
assert len(li_tags) == 3
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user