Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: removing ngrok cluster test #748

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ twilio-python Changelog

Here you can see the full list of changes between each twilio-python release.

[2024-01-04] Version 9.0.0-rc.1
-------------------------------
**Library - Chore**
- [PR #743](https://github.com/twilio/twilio-python/pull/743): sync with main. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)!


[2023-12-06] Version 9.0.0-rc.0
---------------------------
- Release Candidate preparation
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name="twilio",
version="9.0.0-rc.0",
version="9.0.0-rc.1",
description="Twilio API client and TwiML generator",
author="Twilio",
help_center="https://www.twilio.com/help/contact",
Expand Down
163 changes: 79 additions & 84 deletions tests/cluster/test_webhook.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import os
import unittest
import time
import _thread

from http.server import BaseHTTPRequestHandler, HTTPServer
from pyngrok import ngrok
from http.server import BaseHTTPRequestHandler
from twilio.request_validator import RequestValidator
from twilio.rest import Client


class RequestHandler(BaseHTTPRequestHandler):
Expand Down Expand Up @@ -34,81 +29,81 @@ def process_request(self):
)


class WebhookTest(unittest.TestCase):
def setUp(self):
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
self.client = Client(api_key, api_secret, account_sid)

portNumber = 7777
self.validation_server = HTTPServer(("", portNumber), RequestHandler)
self.tunnel = ngrok.connect(portNumber)
self.flow_sid = ""
_thread.start_new_thread(self.start_http_server, ())

def start_http_server(self):
self.validation_server.serve_forever()

def tearDown(self):
self.client.studio.v2.flows(self.flow_sid).delete()
ngrok.kill()
self.validation_server.shutdown()
self.validation_server.server_close()

def create_studio_flow(self, url, method):
flow = self.client.studio.v2.flows.create(
friendly_name="Python Cluster Test Flow",
status="published",
definition={
"description": "Studio Flow",
"states": [
{
"name": "Trigger",
"type": "trigger",
"transitions": [
{
"next": "httpRequest",
"event": "incomingRequest",
},
],
"properties": {},
},
{
"name": "httpRequest",
"type": "make-http-request",
"transitions": [],
"properties": {
"method": method,
"content_type": "application/x-www-form-urlencoded;charset=utf-8",
"url": url,
},
},
],
"initial_state": "Trigger",
"flags": {
"allow_concurrent_calls": True,
},
},
)
return flow

def validate(self, method):
flow = self.create_studio_flow(url=self.tunnel.public_url, method=method)
self.flow_sid = flow.sid
time.sleep(5)
self.client.studio.v2.flows(self.flow_sid).executions.create(
to="to", from_="from"
)

def test_get(self):
time.sleep(5)
self.validate("GET")
time.sleep(5)
self.assertEqual(RequestHandler.is_request_valid, True)

def test_post(self):
time.sleep(5)
self.validate("POST")
time.sleep(5)
self.assertEqual(RequestHandler.is_request_valid, True)
# class WebhookTest(unittest.TestCase):
# def setUp(self):
# api_key = os.environ["TWILIO_API_KEY"]
# api_secret = os.environ["TWILIO_API_SECRET"]
# account_sid = os.environ["TWILIO_ACCOUNT_SID"]
# self.client = Client(api_key, api_secret, account_sid)
#
# portNumber = 7777
# self.validation_server = HTTPServer(("", portNumber), RequestHandler)
# self.tunnel = ngrok.connect(portNumber)
# self.flow_sid = ""
# _thread.start_new_thread(self.start_http_server, ())
#
# def start_http_server(self):
# self.validation_server.serve_forever()
#
# def tearDown(self):
# self.client.studio.v2.flows(self.flow_sid).delete()
# ngrok.kill()
# self.validation_server.shutdown()
# self.validation_server.server_close()
#
# def create_studio_flow(self, url, method):
# flow = self.client.studio.v2.flows.create(
# friendly_name="Python Cluster Test Flow",
# status="published",
# definition={
# "description": "Studio Flow",
# "states": [
# {
# "name": "Trigger",
# "type": "trigger",
# "transitions": [
# {
# "next": "httpRequest",
# "event": "incomingRequest",
# },
# ],
# "properties": {},
# },
# {
# "name": "httpRequest",
# "type": "make-http-request",
# "transitions": [],
# "properties": {
# "method": method,
# "content_type": "application/x-www-form-urlencoded;charset=utf-8",
# "url": url,
# },
# },
# ],
# "initial_state": "Trigger",
# "flags": {
# "allow_concurrent_calls": True,
# },
# },
# )
# return flow
#
# def validate(self, method):
# flow = self.create_studio_flow(url=self.tunnel.public_url, method=method)
# self.flow_sid = flow.sid
# time.sleep(5)
# self.client.studio.v2.flows(self.flow_sid).executions.create(
# to="to", from_="from"
# )
#
# def test_get(self):
# time.sleep(5)
# self.validate("GET")
# time.sleep(5)
# self.assertEqual(RequestHandler.is_request_valid, True)
#
# def test_post(self):
# time.sleep(5)
# self.validate("POST")
# time.sleep(5)
# self.assertEqual(RequestHandler.is_request_valid, True)
2 changes: 1 addition & 1 deletion twilio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version_info__ = ("8", "11", "0")
__version_info__ = ("9", "0", "0-rc.1")
__version__ = ".".join(__version_info__)
30 changes: 15 additions & 15 deletions twilio/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
from twilio.rest.ip_messaging import IpMessaging
from twilio.rest.lookups import Lookups
from twilio.rest.media import Media
from twilio.rest.preview_messaging import PreviewMessaging
from twilio.rest.messaging import Messaging
from twilio.rest.microvisor import Microvisor
from twilio.rest.monitor import Monitor
from twilio.rest.notify import Notify
from twilio.rest.numbers import Numbers
from twilio.rest.preview import Preview
from twilio.rest.preview_messaging import PreviewMessaging
from twilio.rest.pricing import Pricing
from twilio.rest.proxy import Proxy
from twilio.rest.routes import Routes
Expand Down Expand Up @@ -137,13 +137,13 @@ def __init__(
self._ip_messaging: Optional["IpMessaging"] = None
self._lookups: Optional["Lookups"] = None
self._media: Optional["Media"] = None
self._preview_messaging: Optional["PreviewMessaging"] = None
self._messaging: Optional["Messaging"] = None
self._microvisor: Optional["Microvisor"] = None
self._monitor: Optional["Monitor"] = None
self._notify: Optional["Notify"] = None
self._numbers: Optional["Numbers"] = None
self._preview: Optional["Preview"] = None
self._preview_messaging: Optional["PreviewMessaging"] = None
self._pricing: Optional["Pricing"] = None
self._proxy: Optional["Proxy"] = None
self._routes: Optional["Routes"] = None
Expand Down Expand Up @@ -354,6 +354,19 @@ def media(self) -> "Media":
self._media = Media(self)
return self._media

@property
def preview_messaging(self) -> "PreviewMessaging":
"""
Access the PreviewMessaging Twilio Domain

:returns: PreviewMessaging Twilio Domain
"""
if self._preview_messaging is None:
from twilio.rest.preview_messaging import PreviewMessaging

self._preview_messaging = PreviewMessaging(self)
return self._preview_messaging

@property
def messaging(self) -> "Messaging":
"""
Expand Down Expand Up @@ -432,19 +445,6 @@ def preview(self) -> "Preview":
self._preview = Preview(self)
return self._preview

@property
def preview_messaging(self) -> "PreviewMessaging":
"""
Access the Preview Messaging Twilio Domain

:returns: Preview Messaging Twilio Domain
"""
if self._preview_messaging is None:
from twilio.rest.preview_messaging import PreviewMessaging

self._preview_messaging = PreviewMessaging(self)
return self._preview_messaging

@property
def pricing(self) -> "Pricing":
"""
Expand Down
2 changes: 2 additions & 0 deletions twilio/rest/accounts/v1/credential/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def create(

:returns: The created AwsInstance
"""

data = values.of(
{
"Credentials": credentials,
Expand Down Expand Up @@ -352,6 +353,7 @@ async def create_async(

:returns: The created AwsInstance
"""

data = values.of(
{
"Credentials": credentials,
Expand Down
2 changes: 2 additions & 0 deletions twilio/rest/accounts/v1/credential/public_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def create(

:returns: The created PublicKeyInstance
"""

data = values.of(
{
"PublicKey": public_key,
Expand Down Expand Up @@ -356,6 +357,7 @@ async def create_async(

:returns: The created PublicKeyInstance
"""

data = values.of(
{
"PublicKey": public_key,
Expand Down
2 changes: 2 additions & 0 deletions twilio/rest/accounts/v1/safelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def create(self, phone_number: str) -> SafelistInstance:

:returns: The created SafelistInstance
"""

data = values.of(
{
"PhoneNumber": phone_number,
Expand All @@ -86,6 +87,7 @@ async def create_async(self, phone_number: str) -> SafelistInstance:

:returns: The created SafelistInstance
"""

data = values.of(
{
"PhoneNumber": phone_number,
Expand Down
2 changes: 2 additions & 0 deletions twilio/rest/api/v2010/account/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ def create(

:returns: The created AccountInstance
"""

data = values.of(
{
"FriendlyName": friendly_name,
Expand All @@ -845,6 +846,7 @@ async def create_async(

:returns: The created AccountInstance
"""

data = values.of(
{
"FriendlyName": friendly_name,
Expand Down
2 changes: 2 additions & 0 deletions twilio/rest/api/v2010/account/address/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ def create(

:returns: The created AddressInstance
"""

data = values.of(
{
"CustomerName": customer_name,
Expand Down Expand Up @@ -567,6 +568,7 @@ async def create_async(

:returns: The created AddressInstance
"""

data = values.of(
{
"CustomerName": customer_name,
Expand Down
2 changes: 2 additions & 0 deletions twilio/rest/api/v2010/account/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ def create(

:returns: The created ApplicationInstance
"""

data = values.of(
{
"ApiVersion": api_version,
Expand Down Expand Up @@ -674,6 +675,7 @@ async def create_async(

:returns: The created ApplicationInstance
"""

data = values.of(
{
"ApiVersion": api_version,
Expand Down
11 changes: 10 additions & 1 deletion twilio/rest/api/v2010/account/authorized_connect_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"""


from datetime import datetime
from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator
from twilio.base import values
from twilio.base import deserialize, values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
Expand All @@ -34,6 +35,8 @@ class Permission(object):
:ivar connect_app_friendly_name: The name of the Connect App.
:ivar connect_app_homepage_url: The public URL for the Connect App.
:ivar connect_app_sid: The SID that we assigned to the Connect App.
:ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
:ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
:ivar permissions: The set of permissions that you authorized for the Connect App. Can be: `get-all` or `post-all`.
:ivar uri: The URI of the resource, relative to `https://api.twilio.com`.
"""
Expand Down Expand Up @@ -61,6 +64,12 @@ def __init__(
"connect_app_homepage_url"
)
self.connect_app_sid: Optional[str] = payload.get("connect_app_sid")
self.date_created: Optional[datetime] = deserialize.rfc2822_datetime(
payload.get("date_created")
)
self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime(
payload.get("date_updated")
)
self.permissions: Optional[
List["AuthorizedConnectAppInstance.Permission"]
] = payload.get("permissions")
Expand Down
Loading