|
6 | 6 | import logging
|
7 | 7 | import os
|
8 | 8 | import socket
|
| 9 | +import time |
9 | 10 | import unittest
|
10 | 11 | import unittest.mock
|
11 | 12 |
|
@@ -85,32 +86,19 @@ def test_dns_record_abc(self):
|
85 | 86 | record.write(None) # type: ignore[arg-type]
|
86 | 87 |
|
87 | 88 | def test_dns_record_reset_ttl(self):
|
88 |
| - start = r.current_time_millis() |
89 |
| - record = r.DNSRecord( |
90 |
| - 'irrelevant', const._TYPE_SRV, const._CLASS_IN, const._DNS_HOST_TTL, created=start |
91 |
| - ) |
92 |
| - later = start + 1000 |
93 |
| - record2 = r.DNSRecord( |
94 |
| - 'irrelevant', const._TYPE_SRV, const._CLASS_IN, const._DNS_HOST_TTL, created=later |
95 |
| - ) |
| 89 | + record = r.DNSRecord('irrelevant', const._TYPE_SRV, const._CLASS_IN, const._DNS_HOST_TTL) |
| 90 | + time.sleep(1) |
| 91 | + record2 = r.DNSRecord('irrelevant', const._TYPE_SRV, const._CLASS_IN, const._DNS_HOST_TTL) |
96 | 92 | now = r.current_time_millis()
|
97 | 93 |
|
98 | 94 | assert record.created != record2.created
|
99 | 95 | assert record.get_remaining_ttl(now) != record2.get_remaining_ttl(now)
|
100 |
| - assert record.get_percentage_remaining_ttl(now) != record2.get_percentage_remaining_ttl(now) |
101 |
| - assert record2.get_percentage_remaining_ttl(later) == 100 |
102 |
| - assert record2.get_percentage_remaining_ttl(later + (const._DNS_HOST_TTL * 1000 / 2)) == 50 |
103 | 96 |
|
104 | 97 | record.reset_ttl(record2)
|
105 | 98 |
|
106 | 99 | assert record.ttl == record2.ttl
|
107 | 100 | assert record.created == record2.created
|
108 | 101 | assert record.get_remaining_ttl(now) == record2.get_remaining_ttl(now)
|
109 |
| - assert record.get_percentage_remaining_ttl(now) == record2.get_percentage_remaining_ttl(now) |
110 |
| - assert record.get_percentage_remaining_ttl(later) == 100 |
111 |
| - assert record2.get_percentage_remaining_ttl(later) == 100 |
112 |
| - assert record.get_percentage_remaining_ttl(later + (const._DNS_HOST_TTL * 1000 / 2)) == 50 |
113 |
| - assert record2.get_percentage_remaining_ttl(later + (const._DNS_HOST_TTL * 1000 / 2)) == 50 |
114 | 102 |
|
115 | 103 | def test_service_info_dunder(self):
|
116 | 104 | type_ = "_test-srvc-type._tcp.local."
|
|
0 commit comments