Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
9c804bc3
Commit
9c804bc3
authored
10 years ago
by
Paul "LeoNerd" Evans
Browse files
Options
Downloads
Patches
Plain Diff
Check that setting typing notification still works after explicit timeout at REST layer - SYN-230
parent
67d8305a
No related branches found
Branches containing commit
Tags
v1.9.0rc1
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/rest/test_typing.py
+50
-1
50 additions, 1 deletion
tests/rest/test_typing.py
with
50 additions
and
1 deletion
tests/rest/test_typing.py
+
50
−
1
View file @
9c804bc3
...
@@ -21,7 +21,7 @@ from twisted.internet import defer
...
@@ -21,7 +21,7 @@ from twisted.internet import defer
import
synapse.rest.room
import
synapse.rest.room
from
synapse.server
import
HomeServer
from
synapse.server
import
HomeServer
from
..utils
import
MockHttpResource
,
SQLiteMemoryDbPool
,
MockKey
from
..utils
import
MockHttpResource
,
MockClock
,
SQLiteMemoryDbPool
,
MockKey
from
.utils
import
RestTestCase
from
.utils
import
RestTestCase
from
mock
import
Mock
,
NonCallableMock
from
mock
import
Mock
,
NonCallableMock
...
@@ -36,6 +36,8 @@ class RoomTypingTestCase(RestTestCase):
...
@@ -36,6 +36,8 @@ class RoomTypingTestCase(RestTestCase):
@defer.inlineCallbacks
@defer.inlineCallbacks
def
setUp
(
self
):
def
setUp
(
self
):
self
.
clock
=
MockClock
()
self
.
mock_resource
=
MockHttpResource
(
prefix
=
PATH_PREFIX
)
self
.
mock_resource
=
MockHttpResource
(
prefix
=
PATH_PREFIX
)
self
.
auth_user_id
=
self
.
user_id
self
.
auth_user_id
=
self
.
user_id
...
@@ -47,6 +49,7 @@ class RoomTypingTestCase(RestTestCase):
...
@@ -47,6 +49,7 @@ class RoomTypingTestCase(RestTestCase):
hs
=
HomeServer
(
hs
=
HomeServer
(
"
red
"
,
"
red
"
,
clock
=
self
.
clock
,
db_pool
=
db_pool
,
db_pool
=
db_pool
,
http_client
=
None
,
http_client
=
None
,
replication_layer
=
Mock
(),
replication_layer
=
Mock
(),
...
@@ -77,6 +80,30 @@ class RoomTypingTestCase(RestTestCase):
...
@@ -77,6 +80,30 @@ class RoomTypingTestCase(RestTestCase):
return
defer
.
succeed
(
None
)
return
defer
.
succeed
(
None
)
hs
.
get_datastore
().
insert_client_ip
=
_insert_client_ip
hs
.
get_datastore
().
insert_client_ip
=
_insert_client_ip
def
get_room_members
(
room_id
):
if
room_id
==
self
.
room_id
:
return
defer
.
succeed
([
hs
.
parse_userid
(
self
.
user_id
)])
else
:
return
defer
.
succeed
([])
@defer.inlineCallbacks
def
fetch_room_distributions_into
(
room_id
,
localusers
=
None
,
remotedomains
=
None
,
ignore_user
=
None
):
members
=
yield
get_room_members
(
room_id
)
for
member
in
members
:
if
ignore_user
is
not
None
and
member
==
ignore_user
:
continue
if
hs
.
is_mine
(
member
):
if
localusers
is
not
None
:
localusers
.
add
(
member
)
else
:
if
remotedomains
is
not
None
:
remotedomains
.
add
(
member
.
domain
)
hs
.
get_handlers
().
room_member_handler
.
fetch_room_distributions_into
=
(
fetch_room_distributions_into
)
synapse
.
rest
.
room
.
register_servlets
(
hs
,
self
.
mock_resource
)
synapse
.
rest
.
room
.
register_servlets
(
hs
,
self
.
mock_resource
)
self
.
room_id
=
yield
self
.
create_room_as
(
self
.
user_id
)
self
.
room_id
=
yield
self
.
create_room_as
(
self
.
user_id
)
...
@@ -113,3 +140,25 @@ class RoomTypingTestCase(RestTestCase):
...
@@ -113,3 +140,25 @@ class RoomTypingTestCase(RestTestCase):
'
{
"
typing
"
: false}
'
'
{
"
typing
"
: false}
'
)
)
self
.
assertEquals
(
200
,
code
)
self
.
assertEquals
(
200
,
code
)
@defer.inlineCallbacks
def
test_typing_timeout
(
self
):
(
code
,
_
)
=
yield
self
.
mock_resource
.
trigger
(
"
PUT
"
,
"
/rooms/%s/typing/%s
"
%
(
self
.
room_id
,
self
.
user_id
),
'
{
"
typing
"
: true,
"
timeout
"
: 30000}
'
)
self
.
assertEquals
(
200
,
code
)
self
.
assertEquals
(
self
.
event_source
.
get_current_key
(),
1
)
self
.
clock
.
advance_time
(
31
);
self
.
assertEquals
(
self
.
event_source
.
get_current_key
(),
2
)
(
code
,
_
)
=
yield
self
.
mock_resource
.
trigger
(
"
PUT
"
,
"
/rooms/%s/typing/%s
"
%
(
self
.
room_id
,
self
.
user_id
),
'
{
"
typing
"
: true,
"
timeout
"
: 30000}
'
)
self
.
assertEquals
(
200
,
code
)
self
.
assertEquals
(
self
.
event_source
.
get_current_key
(),
3
)
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