4
4
"""
5
5
6
6
from codeforlife .tests import ModelTestCase
7
- from django .db import IntegrityError
8
7
9
8
from .agreement_signature import AgreementSignature
10
- from .contributor import Contributor
11
9
12
10
13
11
class TestAgreementSignature (ModelTestCase [AgreementSignature ]):
@@ -17,36 +15,17 @@ class TestAgreementSignature(ModelTestCase[AgreementSignature]):
17
15
18
16
def setUp (self ):
19
17
self .agreement_signature = AgreementSignature .objects .get (pk = 1 )
20
- self .contributor1 = Contributor .objects .get (pk = 1 )
21
18
22
19
def test_str (self ):
23
- """Parsing a contributor object instance to returns its name."""
20
+ """
21
+ Parsing an agreement-signature instance to a string
22
+ that returns the contributor's primary key,
23
+ the first 7 characters of the agreement's commit ID
24
+ and the timestamp of when the agreement was signed.
25
+ """
24
26
commit_id = self .agreement_signature .agreement_id [:7 ]
25
27
time = self .agreement_signature .signed_at
26
- cont = f"Contributor { self .agreement_signature .contributor } signed"
28
+ cont = f"Contributor { self .agreement_signature .contributor . pk } signed"
27
29
repo = f"{ commit_id } at { time } "
28
30
expected_str = f"{ cont } { repo } "
29
31
assert str (self .agreement_signature ) == expected_str
30
-
31
- def test_unique_fields (self ):
32
- """Test the unique fields functionality"""
33
- new_contributor = Contributor .objects .create (
34
- id = 738237 ,
35
-
36
- name = "new contributor" ,
37
- location = "london" ,
38
- html_url = "https://github.com/newcontributor" ,
39
- avatar_url = "https://contributornew.github.io/" ,
40
- )
41
- AgreementSignature .objects .create (
42
- contributor = new_contributor ,
43
- agreement_id = "pyu66uehr8dgd43vc37232fef0898df3f3f31fga" ,
44
- signed_at = "2024-01-02T12:00:00Z" ,
45
- )
46
-
47
- with self .assertRaises (IntegrityError ):
48
- AgreementSignature .objects .create (
49
- contributor = new_contributor ,
50
- agreement_id = "pyu66uehr8dgd43vc37232fef0898df3f3f31fga" ,
51
- signed_at = "2024-01-02T12:00:00Z" ,
52
- )
0 commit comments