Skip to content

Commit

Permalink
test_matrix_message_submitted_frontend_like_job_id
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Oct 2, 2023
1 parent afab706 commit f59f46d
Showing 1 changed file with 13 additions and 41 deletions.
54 changes: 13 additions & 41 deletions tests/test_matrix_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ def test_matrix_message_run_analysis_callback(gunicorn_dispatcher_long_living_fi

@pytest.mark.test_matrix
@pytest.mark.not_safe_parallel
def test_matrix_message_submitted_same_job(dispatcher_live_fixture_with_matrix_options, dispatcher_local_matrix_message_server):
def test_matrix_message_submitted_same_job(dispatcher_live_fixture_with_matrix_options,
dispatcher_local_matrix_message_server):
# remove all the current scratch folders
DispatcherJobState.remove_scratch_folders()

Expand Down Expand Up @@ -567,44 +568,18 @@ def test_matrix_message_submitted_same_job(dispatcher_live_fixture_with_matrix_o

@pytest.mark.test_matrix
@pytest.mark.not_safe_parallel
def test_email_unnecessary_job_id(dispatcher_live_fixture, dispatcher_local_mail_server):
# remove all the current scratch folders
DispatcherJobState.remove_scratch_folders()

server = dispatcher_live_fixture

dict_param = dict(
query_status="new",
query_type="Real",
instrument="empty-async",
product_type="dummy",
job_id="something-else"
)

# this should return status submitted, so email sent
c = requests.get(server + "/run_analysis",
dict_param
)

assert c.status_code == 400

jdata = c.json()
assert 'unnecessarily' in jdata['error']
assert dict_param['job_id'] in jdata['error']


@pytest.mark.test_matrix
@pytest.mark.not_safe_parallel
def test_email_submitted_frontend_like_job_id(dispatcher_live_fixture, dispatcher_local_mail_server):
def test_matrix_message_submitted_frontend_like_job_id(dispatcher_live_fixture_with_matrix_options,
dispatcher_local_matrix_message_server):
DispatcherJobState.remove_scratch_folders()

server = dispatcher_live_fixture
server = dispatcher_live_fixture_with_matrix_options
logger.info("constructed server: %s", server)

# email content in plain text and html format
smtp_server_log = dispatcher_local_mail_server.local_smtp_output_json_fn
token_payload = {**default_token_payload,
"mxroomid": dispatcher_local_matrix_message_server.room_id
}

encoded_token = jwt.encode(default_token_payload, secret_key, algorithm='HS256')
encoded_token = jwt.encode(token_payload, secret_key, algorithm='HS256')

dict_param = dict(
query_status="new",
Expand All @@ -616,7 +591,7 @@ def test_email_submitted_frontend_like_job_id(dispatcher_live_fixture, dispatche
)

# this should return status submitted, so email sent
c = requests.get(server + "/run_analysis",
c = requests.get(os.path.join(server, "run_analysis"),
dict_param
)

Expand All @@ -626,10 +601,7 @@ def test_email_submitted_frontend_like_job_id(dispatcher_live_fixture, dispatche

jdata = c.json()
assert jdata['exit_status']['job_status'] == 'submitted'
assert jdata['exit_status']['email_status'] == 'email sent'

# check the email in the email folders, and that the first one was produced

dispatcher_job_state.assert_email(state="submitted")
dispatcher_local_mail_server.assert_email_number(1)
assert 'matrix_message_status' in jdata['exit_status']
assert jdata['exit_status']['matrix_message_status'] == 'matrix message sent'

dispatcher_job_state.assert_matrix_message(state="submitted")

0 comments on commit f59f46d

Please sign in to comment.