-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtest_app.py
More file actions
35 lines (25 loc) · 925 Bytes
/
test_app.py
File metadata and controls
35 lines (25 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from pathlib import Path
from unittest.mock import patch
import pytest
from flask import Flask
from flask.testing import FlaskClient
from local_app.app import create_app
from tests.helpers import load_webhook_json
_TEST_FILES_PATH = Path(__file__).parent.parent.parent / "files/webhooks"
@pytest.fixture()
def app() -> Flask:
app = create_app()
app.config.update({
"TESTING": True,
})
return app
@pytest.fixture()
def client(app: Flask) -> FlaskClient:
return app.test_client()
class TestApp:
@patch("local_app.app._enqueue_work")
def test_app_receive_webhook(self, mock_verify_app_installation, client) -> None:
webhook = load_webhook_json(_TEST_FILES_PATH / "canvas_initialize_webhook.json")
response = client.post("1/webhooks/canvas", json=webhook.to_dict())
assert response.status_code == 200
mock_verify_app_installation.assert_called_once()