Enhance documentation, implement Twilio OTP delivery, and update payment gateway methods. Updated AGENTS.md and README.md for clarity on ExecPlans and architecture. Added Twilio as a dependency and implemented capture/refund methods in MoyasarGateway. Improved frontend routing with react-router-dom and added authentication context. Updated styles and localization files for better user experience.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""Tests for Twilio OTP provider implementation."""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch("apps.accounts.services.otp.TwilioOtpProvider._get_client")
|
||||
def test_twilio_send_sms_calls_client(mock_get_client):
|
||||
from apps.accounts.services.otp import TwilioOtpProvider
|
||||
|
||||
mock_client = MagicMock()
|
||||
mock_get_client.return_value = mock_client
|
||||
|
||||
with patch.dict("os.environ", {
|
||||
"TWILIO_ACCOUNT_SID": "AC123",
|
||||
"TWILIO_AUTH_TOKEN": "token",
|
||||
"TWILIO_FROM_NUMBER": "+966500000000",
|
||||
}):
|
||||
provider = TwilioOtpProvider()
|
||||
provider.send_sms("+966512345678", "Your code is 123456")
|
||||
|
||||
mock_client.messages.create.assert_called_once_with(
|
||||
body="Your code is 123456",
|
||||
from_="+966500000000",
|
||||
to="+966512345678",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch("apps.accounts.services.otp.TwilioOtpProvider._get_client")
|
||||
def test_twilio_send_whatsapp_calls_client(mock_get_client):
|
||||
from apps.accounts.services.otp import TwilioOtpProvider
|
||||
|
||||
mock_client = MagicMock()
|
||||
mock_get_client.return_value = mock_client
|
||||
|
||||
with patch.dict("os.environ", {
|
||||
"TWILIO_ACCOUNT_SID": "AC123",
|
||||
"TWILIO_AUTH_TOKEN": "token",
|
||||
"TWILIO_FROM_NUMBER": "+966500000000",
|
||||
"TWILIO_WHATSAPP_FROM": "14155238886",
|
||||
}):
|
||||
provider = TwilioOtpProvider()
|
||||
provider.send_whatsapp("+966512345678", "Your code is 123456")
|
||||
|
||||
mock_client.messages.create.assert_called_once_with(
|
||||
body="Your code is 123456",
|
||||
from_="whatsapp:14155238886",
|
||||
to="whatsapp:+966512345678",
|
||||
)
|
||||
Reference in New Issue
Block a user