1
+ from datetime import timedelta
2
+
1
3
from django .conf import settings
2
4
from django .contrib .auth .models import User
3
5
from django .test import TestCase
@@ -33,15 +35,15 @@ def setUp(self):
33
35
self .domain_recently_expired = get (
34
36
Domain , project = self .project , ssl_status = SSL_STATUS_PENDING
35
37
)
36
- self .domain_recently_expired .validation_process_start -= timezone . timedelta (
38
+ self .domain_recently_expired .validation_process_start -= timedelta (
37
39
days = settings .RTD_CUSTOM_DOMAINS_VALIDATION_PERIOD
38
40
)
39
41
self .domain_recently_expired .save ()
40
42
41
43
self .domain_expired = get (
42
44
Domain , project = self .project , ssl_status = SSL_STATUS_PENDING
43
45
)
44
- self .domain_expired .validation_process_start -= timezone . timedelta (
46
+ self .domain_expired .validation_process_start -= timedelta (
45
47
days = settings .RTD_CUSTOM_DOMAINS_VALIDATION_PERIOD + 10
46
48
)
47
49
self .domain_expired .save ()
@@ -59,3 +61,16 @@ def test_pending(self):
59
61
def test_valid (self ):
60
62
domains = set (Domain .objects .valid ().all ())
61
63
self .assertEqual (domains , {self .domain })
64
+
65
+ def test_expired (self ):
66
+ # All expired domains.
67
+ domains = set (Domain .objects .expired ())
68
+ self .assertEqual (domains , {self .domain_expired , self .domain_recently_expired })
69
+
70
+ # Domains that expired today.
71
+ domains = set (Domain .objects .expired (when = timezone .now ()))
72
+ self .assertEqual (domains , {self .domain_recently_expired })
73
+
74
+ # Domains that expired 10 days ago.
75
+ domains = set (Domain .objects .expired (when = timezone .now () - timedelta (days = 10 )))
76
+ self .assertEqual (domains , {self .domain_expired })
0 commit comments