-
Notifications
You must be signed in to change notification settings - Fork 47
/
test_webhooks.py
102 lines (77 loc) · 2.76 KB
/
test_webhooks.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import pytest
# pylint: disable=unused-import
from .context import Webhook
from .fixtures import (
WEBHOOK_ID,
WORKSPACE_ID,
auth_account_live,
auth_account_mock,
auth_live,
auth_mock,
auth_project_live,
auth_project_mock,
password_test_live,
project_api_key_live,
project_id_live,
username_test_live,
webhook_live,
webhook_mock,
webhooks_live,
webhooks_mock,
)
def test_webhook_initiate(webhook_mock):
assert isinstance(webhook_mock, Webhook)
assert webhook_mock.webhook_id == WEBHOOK_ID
assert webhook_mock.workspace_id == WORKSPACE_ID
def test_webhook_info(webhook_mock):
assert webhook_mock.info
assert webhook_mock._info["id"] == WEBHOOK_ID
def test_webhook_trigger_test_event(webhook_mock):
test_event_info = webhook_mock.trigger_test_events()
assert isinstance(test_event_info, dict)
assert test_event_info["testsRun"] >= 1
def test_webhook_update(webhook_mock):
updated_webhook = webhook_mock.update(name="test_info_webhook")
assert isinstance(updated_webhook, Webhook)
assert updated_webhook._info["name"] == "test_info_webhook"
def test_webhook_delete(webhook_mock):
webhook_mock.delete()
def test_get_webhook_events(webhooks_mock):
webhook_events = webhooks_mock.get_webhook_events()
assert isinstance(webhook_events, list)
assert len(webhook_events)
@pytest.mark.live
def test_get_webhook_events_live(webhooks_live):
webhook_events = webhooks_live.get_webhook_events()
assert isinstance(webhook_events, list)
assert len(webhook_events)
def test_get_webhooks(webhooks_mock):
webhooks = webhooks_mock.get_webhooks()
assert isinstance(webhooks, list)
assert isinstance(webhooks[0], Webhook)
def test_get_webhooks_return_json(webhooks_mock):
webhooks = webhooks_mock.get_webhooks(return_json=True)
assert isinstance(webhooks, list)
assert isinstance(webhooks[0], dict)
@pytest.mark.live
def test_get_webhooks_live(webhooks_live):
webhooks = webhooks_live.get_webhooks()
assert isinstance(webhooks, list)
assert len(webhooks) == 3 # TEST_UP42_WEBHOOK_ID env variable needs to be updated
# assert isinstance(webhooks[0], Webhook)
def test_create_webhook(webhooks_mock):
new_webhook = webhooks_mock.create_webhook(
name="test_info_webhook",
url="https://test-webhook-creation.com",
events=["job.status"],
)
assert new_webhook._info["name"] == "test_info_webhook"
@pytest.mark.live
def test_create_webhook_live(webhooks_live):
new_webhook = webhooks_live.create_webhook(
name="test_webhook_creation",
url="https://test-webhook-creation.com",
events=["job.status"],
)
assert new_webhook._info["name"] == "test_webhook_creation"
new_webhook.delete()