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
Container registry
Model registry
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
Maunium
synapse
Commits
65c6aee6
Unverified
Commit
65c6aee6
authored
5 years ago
by
Brendan Abolivier
Browse files
Options
Downloads
Patches
Plain Diff
Un-remove room purge test
parent
aeda1b3b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/rest/client/v1/test_rooms.py
+72
-0
72 additions, 0 deletions
tests/rest/client/v1/test_rooms.py
with
72 additions
and
0 deletions
tests/rest/client/v1/test_rooms.py
+
72
−
0
View file @
65c6aee6
...
@@ -815,6 +815,78 @@ class RoomMessageListTestCase(RoomBase):
...
@@ -815,6 +815,78 @@ class RoomMessageListTestCase(RoomBase):
self
.
assertTrue
(
"
chunk
"
in
channel
.
json_body
)
self
.
assertTrue
(
"
chunk
"
in
channel
.
json_body
)
self
.
assertTrue
(
"
end
"
in
channel
.
json_body
)
self
.
assertTrue
(
"
end
"
in
channel
.
json_body
)
def
test_room_messages_purge
(
self
):
store
=
self
.
hs
.
get_datastore
()
pagination_handler
=
self
.
hs
.
get_pagination_handler
()
# Send a first message in the room, which will be removed by the purge.
first_event_id
=
self
.
helper
.
send
(
self
.
room_id
,
"
message 1
"
)[
"
event_id
"
]
first_token
=
self
.
get_success
(
store
.
get_topological_token_for_event
(
first_event_id
)
)
# Send a second message in the room, which won't be removed, and which we'll
# use as the marker to purge events before.
second_event_id
=
self
.
helper
.
send
(
self
.
room_id
,
"
message 2
"
)[
"
event_id
"
]
second_token
=
self
.
get_success
(
store
.
get_topological_token_for_event
(
second_event_id
)
)
# Send a third event in the room to ensure we don't fall under any edge case
# due to our marker being the latest forward extremity in the room.
self
.
helper
.
send
(
self
.
room_id
,
"
message 3
"
)
# Check that we get the first and second message when querying /messages.
request
,
channel
=
self
.
make_request
(
"
GET
"
,
"
/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s
"
%
(
self
.
room_id
,
second_token
,
json
.
dumps
({
"
types
"
:
[
EventTypes
.
Message
]})),
)
self
.
render
(
request
)
self
.
assertEqual
(
channel
.
code
,
200
,
channel
.
json_body
)
chunk
=
channel
.
json_body
[
"
chunk
"
]
self
.
assertEqual
(
len
(
chunk
),
2
,
[
event
[
"
content
"
]
for
event
in
chunk
])
# Purge every event before the second event.
purge_id
=
random_string
(
16
)
pagination_handler
.
_purges_by_id
[
purge_id
]
=
PurgeStatus
()
self
.
get_success
(
pagination_handler
.
_purge_history
(
purge_id
=
purge_id
,
room_id
=
self
.
room_id
,
token
=
second_token
,
delete_local_events
=
True
,
)
)
# Check that we only get the second message through /message now that the first
# has been purged.
request
,
channel
=
self
.
make_request
(
"
GET
"
,
"
/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s
"
%
(
self
.
room_id
,
second_token
,
json
.
dumps
({
"
types
"
:
[
EventTypes
.
Message
]})),
)
self
.
render
(
request
)
self
.
assertEqual
(
channel
.
code
,
200
,
channel
.
json_body
)
chunk
=
channel
.
json_body
[
"
chunk
"
]
self
.
assertEqual
(
len
(
chunk
),
1
,
[
event
[
"
content
"
]
for
event
in
chunk
])
# Check that we get no event, but also no error, when querying /messages with
# the token that was pointing at the first event, because we don't have it
# anymore.
request
,
channel
=
self
.
make_request
(
"
GET
"
,
"
/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s
"
%
(
self
.
room_id
,
first_token
,
json
.
dumps
({
"
types
"
:
[
EventTypes
.
Message
]})),
)
self
.
render
(
request
)
self
.
assertEqual
(
channel
.
code
,
200
,
channel
.
json_body
)
chunk
=
channel
.
json_body
[
"
chunk
"
]
self
.
assertEqual
(
len
(
chunk
),
0
,
[
event
[
"
content
"
]
for
event
in
chunk
])
class
RoomSearchTestCase
(
unittest
.
HomeserverTestCase
):
class
RoomSearchTestCase
(
unittest
.
HomeserverTestCase
):
servlets
=
[
servlets
=
[
...
...
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