Skip to content

Commit 18decc5

Browse files
committed
Fix doc strings
1 parent f7f88b4 commit 18decc5

File tree

4 files changed

+21
-89
lines changed

4 files changed

+21
-89
lines changed

api/serializers/agreement_signature.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111

1212
class AgreementSignatureSerializer(ModelSerializer[User, AgreementSignature]):
13-
"""Agreement serializer"""
13+
"""Agreement serializer class"""
1414

1515
class Meta:
16-
"""Specify fields for the serializer"""
17-
1816
model = AgreementSignature
1917
fields = "__all__"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
© Ocado Group
3+
Created on 12/07/2024 at 17:16:58(+01:00).
4+
"""
5+
6+
from codeforlife.tests import ModelSerializerTestCase
7+
from codeforlife.user.models import User
8+
9+
from ..models import AgreementSignature
10+
from .agreement_signature import AgreementSignatureSerializer
11+
12+
13+
class TestAgreementSignatureSerializer(
14+
ModelSerializerTestCase[User, AgreementSignature]
15+
):
16+
"""Test the Agreement Signature serializers"""
17+
18+
model_serializer_class = AgreementSignatureSerializer

api/serializers/contributor.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99

1010

1111
class ContributorSerializer(ModelSerializer[User, Contributor]):
12-
"""Contributor class"""
12+
"""Contributor serializer class"""
1313

1414
class Meta:
15-
"""Specify fields for the serializer"""
16-
1715
model = Contributor
1816
fields = "__all__"

api/serializers/contributor_test.py

+1-83
Original file line numberDiff line numberDiff line change
@@ -11,88 +11,6 @@
1111

1212

1313
class TestContributorSerializer(ModelSerializerTestCase[User, Contributor]):
14-
"""Test the functionality of the serializers"""
14+
"""Test the Contributor serializers"""
1515

1616
model_serializer_class = ContributorSerializer
17-
18-
def setUp(self):
19-
"""Set up data to be used for testing"""
20-
self.data1 = {
21-
"id": 1,
22-
"email": "[email protected]",
23-
"name": "Cont One",
24-
"location": "London",
25-
"html_url": "http://github.com/cont1",
26-
"avatar_url": "https://testcont.github.io/gravatar-url-generator/",
27-
}
28-
29-
self.data2 = {
30-
"id": 2,
31-
"email": "[email protected]",
32-
"name": "Cont Two",
33-
"location": "London",
34-
"html_url": "http://github.com/cont2",
35-
"avatar_url": "https://cont2.github.io/gravatar-url-generator/",
36-
}
37-
38-
def test_create(self):
39-
"""Create a contributor"""
40-
self.assert_create(validated_data=self.data1, new_data=self.data1)
41-
42-
def test_create_list(self):
43-
"""List all contributor"""
44-
# Create multiple Contributors
45-
self.assert_create(validated_data=self.data1, new_data=self.data1)
46-
self.assert_create(validated_data=self.data2, new_data=self.data2)
47-
48-
# Compare results
49-
queryset = Contributor.objects.all()
50-
assert len(queryset) == 2
51-
52-
def test_get_first(self):
53-
"""Retrieve the first object"""
54-
# Create multiple Contributors
55-
self.assert_create(validated_data=self.data1, new_data=self.data1)
56-
self.assert_create(validated_data=self.data2, new_data=self.data2)
57-
58-
# Retrieve the first and compare
59-
cont = Contributor.objects.first()
60-
serializer = ContributorSerializer(cont)
61-
assert serializer.data["id"] == self.data1["id"]
62-
63-
def test_get_any(self):
64-
""" " Retrieve any object using its id"""
65-
# Create multiple Contributors
66-
self.assert_create(validated_data=self.data1, new_data=self.data1)
67-
self.assert_create(validated_data=self.data2, new_data=self.data2)
68-
69-
# Retrieve by id and compare
70-
cont = Contributor.objects.get(id=2)
71-
serializer = ContributorSerializer(cont)
72-
assert serializer.data["id"] == self.data2["id"]
73-
74-
def test_update(self):
75-
"""Updating a single contributor"""
76-
# Create a new contributor
77-
cont = Contributor.objects.create(
78-
id=1,
79-
80-
name="Cont One",
81-
location="London",
82-
html_url="http://github.com/cont1",
83-
avatar_url="https://testcont.github.io/gravatar-url-generator/",
84-
)
85-
86-
# Expected Results
87-
new_data = {"email": "[email protected]", "name": "New Name"}
88-
expected = {
89-
"id": 1,
90-
"email": "[email protected]",
91-
"name": "New Name",
92-
"location": "London",
93-
"html_url": "http://github.com/cont1",
94-
"avatar_url": "https://testcont.github.io/gravatar-url-generator/",
95-
}
96-
self.assert_update(
97-
instance=cont, validated_data=new_data, new_data=expected
98-
)

0 commit comments

Comments
 (0)