Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
11860637
Commit
11860637
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Tests
parent
f9d3665c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_dns.py
+29
-2
29 additions, 2 deletions
tests/test_dns.py
with
29 additions
and
2 deletions
tests/test_dns.py
+
29
−
2
View file @
11860637
...
...
@@ -21,6 +21,8 @@ from mock import Mock
from
synapse.http.endpoint
import
resolve_service
from
tests.utils
import
MockClock
class
DnsTestCase
(
unittest
.
TestCase
):
...
...
@@ -63,14 +65,14 @@ class DnsTestCase(unittest.TestCase):
self
.
assertEquals
(
servers
[
0
].
host
,
ip_address
)
@defer.inlineCallbacks
def
test_from_cache
(
self
):
def
test_from_cache
_expired_and_dns_fail
(
self
):
dns_client_mock
=
Mock
()
dns_client_mock
.
lookupService
.
return_value
=
defer
.
fail
(
error
.
DNSServerError
())
service_name
=
"
test_service.examle.com
"
entry
=
Mock
(
spec_set
=
[
"
expires
"
])
entry
.
expires
=
999999999
entry
.
expires
=
0
cache
=
{
service_name
:
[
entry
]
...
...
@@ -85,6 +87,31 @@ class DnsTestCase(unittest.TestCase):
self
.
assertEquals
(
len
(
servers
),
1
)
self
.
assertEquals
(
servers
,
cache
[
service_name
])
@defer.inlineCallbacks
def
test_from_cache
(
self
):
clock
=
MockClock
()
dns_client_mock
=
Mock
(
spec_set
=
[
'
lookupService
'
])
dns_client_mock
.
lookupService
=
Mock
(
spec_set
=
[])
service_name
=
"
test_service.examle.com
"
entry
=
Mock
(
spec_set
=
[
"
expires
"
])
entry
.
expires
=
999999999
cache
=
{
service_name
:
[
entry
]
}
servers
=
yield
resolve_service
(
service_name
,
dns_client
=
dns_client_mock
,
cache
=
cache
,
clock
=
clock
,
)
self
.
assertFalse
(
dns_client_mock
.
lookupService
.
called
)
self
.
assertEquals
(
len
(
servers
),
1
)
self
.
assertEquals
(
servers
,
cache
[
service_name
])
@defer.inlineCallbacks
def
test_empty_cache
(
self
):
dns_client_mock
=
Mock
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment