Skip to content

Commit

Permalink
tests: refactor end meeting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Feb 20, 2024
1 parent b7f9193 commit 5ac9193
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
3 changes: 2 additions & 1 deletion web/b3desk/models/meetings.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ def get_role(self, hashed_role, user_id=None):
return role

def end_bbb(self):
self.bbb.end()
data = self.bbb.end()
return data and data["returncode"] == "SUCCESS"


def get_quick_meeting_from_user_and_random_string(user, random_string=None):
Expand Down
2 changes: 0 additions & 2 deletions web/b3desk/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,6 @@ def save_meeting():
)

if meeting.is_running():
EndMeetingForm()
EndMeetingForm.meeting_id.data = meeting.id
return render_template(
"meeting/end.html",
meeting=meeting,
Expand Down
11 changes: 0 additions & 11 deletions web/tests/meeting/test_end.py

This file was deleted.

42 changes: 34 additions & 8 deletions web/tests/meeting/test_meeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@


@pytest.fixture()
def mocked_is_meeting_running(mocker):
def mock_meeting_is_running(mocker):
mocker.patch("b3desk.models.meetings.Meeting.is_running", return_value=True)


@pytest.fixture()
def mock_meeting_is_not_running(mocker):
mocker.patch("b3desk.models.meetings.Meeting.is_running", return_value=False)


Expand Down Expand Up @@ -45,7 +50,7 @@ def test_edit_meeting(client_app, authenticated_user, meeting, bbb_response):
assert response.template == "meeting/wizard.html"


def test_save_new_meeting(client_app, authenticated_user, mocked_is_meeting_running):
def test_save_new_meeting(client_app, authenticated_user, mock_meeting_is_not_running):
res = client_app.get("/meeting/new")
res.form["name"] = "Mon meeting de test"
res.form["welcome"] = "Bienvenue dans mon meeting de test"
Expand Down Expand Up @@ -96,8 +101,8 @@ def test_save_new_meeting(client_app, authenticated_user, mocked_is_meeting_runn
assert meeting.allowStartStopRecording is True


def test_save_existing_meeting(
client_app, authenticated_user, meeting, mocked_is_meeting_running
def test_save_existing_meeting_not_running(
client_app, authenticated_user, meeting, mock_meeting_is_not_running
):
assert len(Meeting.query.all()) == 1

Expand Down Expand Up @@ -149,8 +154,29 @@ def test_save_existing_meeting(
assert meeting.allowStartStopRecording is True


def test_save_existing_meeting_running(
mocker, client_app, authenticated_user, meeting, mock_meeting_is_running
):
mocker.patch("b3desk.models.meetings.Meeting.end_bbb", return_value=True)
assert len(Meeting.query.all()) == 1

res = client_app.get("/meeting/edit/1")
res.form["welcome"] = "Bienvenue dans mon meeting de test"

res = res.form.submit()
assert res.template == "meeting/end.html"
assert ("success", "meeting modifications prises en compte") in res.flashes

assert len(Meeting.query.all()) == 1
meeting = db.session.get(Meeting, 1)
assert meeting.welcome == "Bienvenue dans mon meeting de test"

res = res.form.submit()
assert ("success", "Séminaire « meeting » terminé(e)") in res.flashes


def test_save_moderatorOnlyMessage_too_long(
client_app, authenticated_user, mocked_is_meeting_running
client_app, authenticated_user, mock_meeting_is_not_running
):
res = client_app.get("/meeting/new")
moderator_only_message = "a" * (MODERATOR_ONLY_MESSAGE_MAXLENGTH + 1)
Expand All @@ -164,7 +190,7 @@ def test_save_moderatorOnlyMessage_too_long(


def test_save_no_recording_by_default(
client_app, authenticated_user, mocked_is_meeting_running
client_app, authenticated_user, mock_meeting_is_not_running
):
res = client_app.get("/meeting/new")
res.form["name"] = "Mon meeting de test"
Expand All @@ -186,7 +212,7 @@ def test_save_no_recording_by_default(


def test_save_meeting_in_no_recording_environment(
client_app, authenticated_user, mocked_is_meeting_running
client_app, authenticated_user, mock_meeting_is_not_running
):
assert len(Meeting.query.all()) == 0
client_app.app.config["RECORDING"] = False
Expand Down Expand Up @@ -292,7 +318,7 @@ def test_create(client_app, meeting, mocker, bbb_response):


def test_create_without_logout_url_gets_default(
app, client_app, authenticated_user, mocked_is_meeting_running
app, client_app, authenticated_user, mock_meeting_is_not_running
):
res = client_app.get("/meeting/new")
res = res.form.submit()
Expand Down

0 comments on commit 5ac9193

Please sign in to comment.