5
5
import respx
6
6
from httpx import Request
7
7
8
+ import replicate
8
9
from replicate .client import Client
9
10
from replicate .webhook import (
10
11
InvalidSecretKeyError ,
11
12
InvalidSignatureError ,
12
13
InvalidTimestampError ,
13
14
MissingWebhookBodyError ,
14
15
MissingWebhookHeaderError ,
15
- Webhooks ,
16
16
WebhookSigningSecret ,
17
17
)
18
18
@@ -69,7 +69,9 @@ def test_validate_webhook_invalid_signature(webhook_signing_secret):
69
69
body = '{"test": 2432232314}'
70
70
71
71
with pytest .raises (InvalidSignatureError , match = "Webhook signature is invalid" ):
72
- Webhooks .validate (headers = headers , body = body , secret = webhook_signing_secret )
72
+ replicate .webhooks .validate (
73
+ headers = headers , body = body , secret = webhook_signing_secret
74
+ )
73
75
74
76
75
77
def test_validate_webhook_missing_webhook_id (webhook_signing_secret ):
@@ -79,7 +81,9 @@ def test_validate_webhook_missing_webhook_id(webhook_signing_secret):
79
81
body = '{"test": 2432232314}'
80
82
81
83
with pytest .raises (MissingWebhookHeaderError , match = "Missing webhook id" ):
82
- Webhooks .validate (headers = headers , body = body , secret = webhook_signing_secret )
84
+ replicate .webhooks .validate (
85
+ headers = headers , body = body , secret = webhook_signing_secret
86
+ )
83
87
84
88
85
89
def test_validate_webhook_invalid_secret ():
@@ -92,7 +96,7 @@ def test_validate_webhook_invalid_secret():
92
96
body = '{"test": 2432232314}'
93
97
94
98
with pytest .raises (InvalidSecretKeyError , match = "Invalid secret key format" ):
95
- Webhooks .validate (
99
+ replicate . webhooks .validate (
96
100
headers = headers ,
97
101
body = body ,
98
102
secret = WebhookSigningSecret (key = "invalid_secret_format" ),
@@ -104,7 +108,7 @@ def test_validate_webhook_missing_headers(webhook_signing_secret):
104
108
body = '{"test": 2432232314}'
105
109
106
110
with pytest .raises (MissingWebhookHeaderError , match = "Missing webhook headers" ):
107
- Webhooks .validate (
111
+ replicate . webhooks .validate (
108
112
headers = headers , # type: ignore
109
113
body = body ,
110
114
secret = webhook_signing_secret ,
@@ -121,7 +125,7 @@ def test_validate_webhook_missing_body(webhook_signing_secret):
121
125
body = None
122
126
123
127
with pytest .raises (MissingWebhookBodyError , match = "Missing webhook body" ):
124
- Webhooks .validate (
128
+ replicate . webhooks .validate (
125
129
headers = headers ,
126
130
body = body , # type: ignore
127
131
secret = webhook_signing_secret ,
@@ -154,7 +158,7 @@ def test_validate_webhook_timestamp(
154
158
with pytest .raises (
155
159
(InvalidTimestampError if timestamp_invalid else InvalidSignatureError ),
156
160
):
157
- Webhooks .validate (
161
+ replicate . webhooks .validate (
158
162
headers = headers ,
159
163
body = body ,
160
164
secret = webhook_signing_secret ,
0 commit comments