Skip to content

Commit 63e2c8f

Browse files
authored
Merge pull request #174 from plivo/fix-tests
Fix tests-cases
2 parents 3b0052a + 291a827 commit 63e2c8f

39 files changed

Lines changed: 199 additions & 111 deletions

.github/workflows/unitTests.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: UnitTests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
name: UnitTests
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [2.7, 3.5, 3.6, 3.7]
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Display Python version
25+
run: python -c "import sys; print(sys.version)"
26+
- name: Dependencies Installation
27+
run: |
28+
pip install tox
29+
- name: Run Tests
30+
run: |
31+
python --version
32+
tox -e py

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## [4.18.1](https://github.com/plivo/plivo-python/tree/v4.18.1) (2021-07-16)
4+
- Updates to [add a member a multi-party call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant).
5+
- Remove validation range for `delay` and `ringtimeout` parameters.
6+
- Add appropriate error message for multiple `ringtimeout` and `delaydial` values.
7+
- Fix the agent limit validation bug so that it only checks when multiple `to` param values are supplied.
8+
- Fix the multiparty call and other voice API UT's.
9+
310
## [4.18.0](https://github.com/plivo/plivo-python/tree/v4.18.0) (2021-07-13)
411
- Power pack ID has been included to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message).
512
- Support for filtering messages by Power pack ID has been added to the [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# plivo-python
22

3-
[![Build Status](https://travis-ci.org/plivo/plivo-python.svg?branch=master)](https://travis-ci.org/plivo/plivo-python)
3+
[![UnitTests](https://github.com/plivo/plivo-python/actions/workflows/unitTests.yml/badge.svg?branch=master)](https://github.com/plivo/plivo-python/actions/workflows/unitTests.yml)
44
[![PyPI](https://img.shields.io/pypi/v/plivo.svg)](https://pypi.python.org/pypi/plivo)
55
[![PyPI](https://img.shields.io/pypi/pyversions/plivo.svg)](https://pypi.python.org/pypi/plivo)
66
[![PyPI](https://img.shields.io/pypi/l/plivo.svg)](https://pypi.python.org/pypi/plivo)

plivo/resources/multipartycall.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ def get(self, uuid=None, friendly_name=None):
228228
of_type_exact(str),
229229
one_of(is_url(), is_in(('real', 'none'), case_sensitive=False, case_type='lower')),
230230
)],
231-
ring_timeout=[optional(one_of(of_type_exact(str), of_type_exact(int)), multiple_valid_integers(15, 120))],
232-
delay_dial=[optional(one_of(of_type_exact(str), of_type_exact(int)), multiple_valid_integers(0, 120))],
231+
ring_timeout=[optional(one_of(of_type_exact(str), of_type_exact(int)), multiple_valid_integers())],
232+
delay_dial=[optional(one_of(of_type_exact(str), of_type_exact(int)), multiple_valid_integers())],
233233
max_duration=[optional(
234234
of_type_exact(int),
235235
check(lambda max_duration: 300 <= max_duration <= 28800, '300 < max_duration <= 28800'))],
@@ -331,10 +331,14 @@ def add_participant(self,
331331
raise ValidationError('specify either call_uuid or (from, to)')
332332
if call_uuid is None and (not from_ or not to_):
333333
raise ValidationError('specify (from, to) when not adding an existing call_uuid to multi party participant')
334-
if len(to_.split('<')) > 1 and role.lower() != "agent":
334+
if to_ and len(to_.split('<')) > 1 and role.lower() != "agent":
335335
raise ValidationError('Multiple to_ values given for role ' + role)
336-
elif len(to_.split('<')) > 20:
336+
elif to_ and len(to_.split('<')) > 20:
337337
raise ValidationError('No of to_ values provided should be lesser than 20')
338+
if to_ and len(str(ring_timeout).split('<')) > len(to_.split('<')):
339+
raise ValidationError("RingTimeout:number of ring_timeout(s) should be same as number of destination(s)")
340+
if to_ and len(str(delay_dial).split('<')) > len(to_.split('<')):
341+
raise ValidationError("DelayDial:number of delay_dial(s) should be same as number of destination(s)")
338342
return self.client.request('POST', ('MultiPartyCall', mpc_id, 'Participant'),
339343
self.__clean_identifiers(to_param_dict(self.add_participant, locals())),
340344
is_voice_request=True)

plivo/utils/jwt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import absolute_import
12
import jwt, time
23
from plivo.utils.validators import *
34

plivo/utils/validators.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,27 +180,17 @@ def f(name, value):
180180
return required(f)
181181

182182

183-
def multiple_valid_integers(lowerbound, upperbound):
183+
def multiple_valid_integers():
184184
def f(name, value):
185-
if isinstance(value, int):
186-
if value >= lowerbound and value <= upperbound:
187-
return value, []
188-
else:
189-
return None, {name + ' value must be in range ' + str(lowerbound) + ' to ' + str(upperbound)}
190-
else:
185+
if isinstance(value, str):
191186
values = value.split('<')
192187
for i in values:
193-
is_int = True
194188
try:
195189
int(i)
196190
except ValueError:
197-
is_int = False
198-
if is_int:
199-
if int(i) > upperbound or int(i) < lowerbound:
200-
return None, [name + ' destination value must be in range ' + str(lowerbound) + ' to ' + str(upperbound)]
201-
else:
202191
return None, ['{} destination value must be integer'.format(name)]
203192
return value, []
193+
return value, []
204194
return f
205195

206196

plivo/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = '4.18.0'
2+
__version__ = '4.18.1'
33

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name='plivo',
13-
version='4.18.0',
13+
version='4.18.1',
1414
description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML',
1515
long_description=long_description,
1616
url='https://github.com/plivo/plivo-python',
@@ -39,6 +39,7 @@
3939
'six >= 1, < 2',
4040
'decorator >= 4, < 5',
4141
'lxml >= 3, < 5',
42+
'PyJWT==1.7.1'
4243
],
4344
keywords=['plivo', 'plivo xml', 'voice calls', 'sms'],
4445
include_package_data=True,

tests/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from unittest import TestCase
3+
from doctest import Example
4+
from lxml.doctestcompare import LXMLOutputChecker
35

46
from httmock import HTTMock, all_requests
57

@@ -172,3 +174,12 @@ def get_url(self, *args, **kwargs):
172174
self.client.session.auth[0] + \
173175
'/' + '/'.join([quote_plus(arg)
174176
for arg in args]) + '/?' + urlencode(kwargs)
177+
178+
179+
class PlivoXmlTestCase:
180+
181+
def assertXmlEqual(self, got, want):
182+
checker = LXMLOutputChecker()
183+
if not checker.check_output(want, got, 0):
184+
message = checker.output_difference(Example("", want), got, 0)
185+
raise AssertionError(message)

tests/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def decorator(self, *args, **kwargs):
2020
name + '.json'))
2121

2222
try:
23-
with io.open(path) as f:
23+
with io.open(path, encoding='utf-8') as f:
2424
self.expected_response = json.load(f)
2525
self.client.set_expected_response(
2626
status_code=status_code,

0 commit comments

Comments
 (0)