Skip to content

Commit

Permalink
Merge pull request #163 from jadolg/add-rooms-export
Browse files Browse the repository at this point in the history
Add rooms.export endpoint
  • Loading branch information
jadolg authored Aug 9, 2022
2 parents 5fb0439 + f1fcfd7 commit 879e3a8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
python-version: [ '3.8', '3.9' ]
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Lint with black
run: black --check .
- name: Wait for rocket.chat server to be online
run: until curl --silent http://localhost:3000/api/info/; do sleep 15; echo "waiting for Rocket.Chat server to start"; done
run: until curl --silent http://localhost:3000/api/info/; do sleep 15; echo "waiting for Rocket.Chat server to start"; done;
- name: Run tests
run: pytest tests rocketchat_API -x --cov-report xml --cov=./
- name: Upload code coverage
Expand Down
2 changes: 0 additions & 2 deletions docker-compose-test-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ services:

mongo:
image: mongo
ports:
- "27017:27017"
restart: unless-stopped
command: mongod --oplogSize 128 --replSet rs0

Expand Down
14 changes: 11 additions & 3 deletions rocketchat_API/APISections/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,17 @@ def rooms_admin_rooms(self, **kwargs):
return self.call_api_get("rooms.adminRooms", kwargs=kwargs)

def rooms_create_discussion(self, prid, t_name, **kwargs):
"""Creates a new discussion for room. It requires at least one of the following permissions:
start-discussion OR start-discussion-other-user, AND must be with the following setting enabled:
Discussion_enabled."""
"""
Creates a new discussion for room. It requires at least one of the
following permissions: start-discussion OR start-discussion-other-user,
AND must be with the following setting enabled: Discussion_enabled.
"""
return self.call_api_post(
"rooms.createDiscussion", prid=prid, t_name=t_name, kwargs=kwargs
)

def rooms_export(self, rid, atype, aformat="html", **kwargs):
"""Export room to a file or email."""
return self.call_api_post(
"rooms.export", rid=rid, type=atype, format=aformat, kwargs=kwargs
)
7 changes: 5 additions & 2 deletions tests/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@


def test_rooms_upload(logged_rocket):
# ToDo: Find a better way to test that this endpoint actually works fine (when using json and not data fails
# silently)
rooms_upload = logged_rocket.rooms_upload(
"GENERAL", file="tests/assets/avatar.png", description="hey there"
).json()
Expand Down Expand Up @@ -92,3 +90,8 @@ def test_rooms_admin_rooms(logged_rocket):
rooms_with_filter = logged_rocket.rooms_admin_rooms(**{"filter": "general"}).json()
assert rooms_with_filter.get("success")
assert rooms_with_filter.get("rooms")[0].get("_id") == "GENERAL"


def test_rooms_export(logged_rocket):
rooms_export = logged_rocket.rooms_export(rid="GENERAL", atype="file").json()
assert rooms_export.get("success")

0 comments on commit 879e3a8

Please sign in to comment.