Skip to content

Commit 49c6fae

Browse files
committed
Simplify pytest.fixture rooms_list and dependencies
Add group_room, direct_rooms, and team_room to the use / dependency list of fixture rooms_list; remove these dependencies from the tests that depend on rooms_list
1 parent ff1d8d5 commit 49c6fae

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

tests/api/test_rooms.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,29 @@ def room_exists(api, room):
4444
# pytest Fixtures
4545

4646
@pytest.fixture(scope="session")
47-
def rooms_list(api):
48-
return list(api.rooms.list())
47+
def group_room(api):
48+
room = create_room(api, create_string("Room"))
49+
yield room
50+
delete_room(api, room)
4951

5052

5153
@pytest.fixture(scope="session")
5254
def direct_rooms(api, direct_messages):
5355
return [api.rooms.get(message.roomId) for message in direct_messages]
5456

5557

56-
@pytest.fixture(scope="session")
57-
def group_room(api):
58-
room = create_room(api, create_string("Room"))
59-
yield room
60-
delete_room(api, room)
61-
62-
6358
@pytest.fixture(scope="session")
6459
def team_room(api, team):
6560
team_room = create_team_room(api, team, create_string("Team Room"))
6661
yield team_room
6762
delete_room(api, team_room)
6863

6964

65+
@pytest.fixture(scope="session")
66+
def rooms_list(api, group_room, direct_rooms, team_room):
67+
return list(api.rooms.list())
68+
69+
7070
@pytest.fixture
7171
def temp_group_room(api):
7272
room = create_room(api, create_string("Room"))
@@ -87,7 +87,7 @@ def inner(num_rooms):
8787
delete_room(api, room)
8888

8989

90-
# Room Tests
90+
# Tests
9191

9292
class TestRoomsAPI(object):
9393
"""Test RoomsAPI methods."""
@@ -127,13 +127,11 @@ def test_list_direct_rooms(self, api, direct_rooms):
127127
assert len(direct_rooms_list) > 0
128128
assert are_valid_rooms(direct_rooms_list)
129129

130-
def test_list_all_rooms(self, rooms_list, group_room, team_room,
131-
direct_rooms):
130+
def test_list_all_rooms(self, rooms_list):
132131
assert len(rooms_list) > 0
133132
assert are_valid_rooms(rooms_list)
134133

135-
def test_list_rooms_with_paging(self, api, rooms_list, add_rooms,
136-
group_room, team_room, direct_rooms):
134+
def test_list_rooms_with_paging(self, api, rooms_list, add_rooms):
137135
page_size = 2
138136
pages = 3
139137
num_rooms = pages * page_size

0 commit comments

Comments
 (0)