Skip to content

Commit

Permalink
Moved mock settings out of the request context
Browse files Browse the repository at this point in the history
  • Loading branch information
tkamppi committed Sep 22, 2019
1 parent a165aff commit 680230a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/dialog_submission/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def test__verify_signature(
BODY = b"token=xyzz0WbapA4vBCDEFasx0q6G&team_id=T1DC2JH3J&team_domain=testteamnow&channel_id=G8PSS9T3V&channel_name=foobar&user_id=U2CERLKJA&user_name=roadrunner&command=%2Fwebhook-collect&text=&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FT1DC2JH3J%2F397700885554%2F96rGlfmibIGlgcZRskXaIFfN&trigger_id=398738663015.47445629121.803a0bc887a14d10d2c447fce8b6703c"

monkeypatch.setenv("SLACK_SIGNING_SECRET", slack_signing_secret)
request_mock.headers.get.side_effect = get_example_headers
request_mock.get_data.return_value = BODY
time_mock.return_value = timestamp
with app.test_request_context():
request_mock.headers.get.side_effect = get_example_headers
request_mock.get_data.return_value = BODY
time_mock.return_value = timestamp
res = main._verify_signature(flask.request)
assert res == expected_outcome
assert res == expected_outcome
8 changes: 4 additions & 4 deletions src/slash_command/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def test__verify_signature(
BODY = b"token=xyzz0WbapA4vBCDEFasx0q6G&team_id=T1DC2JH3J&team_domain=testteamnow&channel_id=G8PSS9T3V&channel_name=foobar&user_id=U2CERLKJA&user_name=roadrunner&command=%2Fwebhook-collect&text=&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FT1DC2JH3J%2F397700885554%2F96rGlfmibIGlgcZRskXaIFfN&trigger_id=398738663015.47445629121.803a0bc887a14d10d2c447fce8b6703c"

monkeypatch.setenv("SLACK_SIGNING_SECRET", slack_signing_secret)
request_mock.headers.get.side_effect = get_example_headers
request_mock.get_data.return_value = BODY
time_mock.return_value = timestamp
with app.test_request_context():
request_mock.headers.get.side_effect = get_example_headers
request_mock.get_data.return_value = BODY
time_mock.return_value = timestamp
res = main._verify_signature(flask.request)
assert res == expected_outcome
assert res == expected_outcome

0 comments on commit 680230a

Please sign in to comment.