55import respx
66from httpx import Request
77
8+ import replicate
89from replicate .client import Client
910from replicate .webhook import (
1011 InvalidSecretKeyError ,
1112 InvalidSignatureError ,
1213 InvalidTimestampError ,
1314 MissingWebhookBodyError ,
1415 MissingWebhookHeaderError ,
15- Webhooks ,
1616 WebhookSigningSecret ,
1717)
1818
@@ -69,7 +69,9 @@ def test_validate_webhook_invalid_signature(webhook_signing_secret):
6969 body = '{"test": 2432232314}'
7070
7171 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+ )
7375
7476
7577def test_validate_webhook_missing_webhook_id (webhook_signing_secret ):
@@ -79,7 +81,9 @@ def test_validate_webhook_missing_webhook_id(webhook_signing_secret):
7981 body = '{"test": 2432232314}'
8082
8183 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+ )
8387
8488
8589def test_validate_webhook_invalid_secret ():
@@ -92,7 +96,7 @@ def test_validate_webhook_invalid_secret():
9296 body = '{"test": 2432232314}'
9397
9498 with pytest .raises (InvalidSecretKeyError , match = "Invalid secret key format" ):
95- Webhooks .validate (
99+ replicate . webhooks .validate (
96100 headers = headers ,
97101 body = body ,
98102 secret = WebhookSigningSecret (key = "invalid_secret_format" ),
@@ -104,7 +108,7 @@ def test_validate_webhook_missing_headers(webhook_signing_secret):
104108 body = '{"test": 2432232314}'
105109
106110 with pytest .raises (MissingWebhookHeaderError , match = "Missing webhook headers" ):
107- Webhooks .validate (
111+ replicate . webhooks .validate (
108112 headers = headers , # type: ignore
109113 body = body ,
110114 secret = webhook_signing_secret ,
@@ -121,7 +125,7 @@ def test_validate_webhook_missing_body(webhook_signing_secret):
121125 body = None
122126
123127 with pytest .raises (MissingWebhookBodyError , match = "Missing webhook body" ):
124- Webhooks .validate (
128+ replicate . webhooks .validate (
125129 headers = headers ,
126130 body = body , # type: ignore
127131 secret = webhook_signing_secret ,
@@ -154,7 +158,7 @@ def test_validate_webhook_timestamp(
154158 with pytest .raises (
155159 (InvalidTimestampError if timestamp_invalid else InvalidSignatureError ),
156160 ):
157- Webhooks .validate (
161+ replicate . webhooks .validate (
158162 headers = headers ,
159163 body = body ,
160164 secret = webhook_signing_secret ,
0 commit comments