8000 Merge branch 'usage-from-accounts' · Stackdriver/twilio-python@2f2a39f · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 1, 2018. It is now read-only.

Commit 2f2a39f

Browse files
author
Kevin Burke
committed
Merge branch 'usage-from-accounts'
2 parents 1886d01 + 39e2e6d commit 2f2a39f

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ develop-eggs
1212
.installed.cfg
1313
scratch
1414
env
15+
venv
1516

1617
# Installer logs
1718
pip-log.txt

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
10000 1+
venv:
2+
virtualenv venv
3+
4+
install: venv
5+
. venv/bin/activate; pip install .
6+
7+
analysis:
8+
. venv/bin/activate; flake8 --ignore=E123,E126,E128,E501 tests
9+
. venv/bin/activate; flake8 --ignore=F401 twilio
10+
11+
test: analysis
12+
. venv/bin/activate; nosetests

tests/test_accounts.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import unittest
2+
3+
from mock import Mock, patch
4+
5+
from tools import create_mock_json
6+
from twilio.rest.resources import Account
7+
8+
9+
class AccountTest(unittest.TestCase):
10+
11+
@patch("twilio.rest.resources.base.make_twilio_request")
12+
def test_usage_records_subresource(self, request):
13+
resp = create_mock_json("tests/resources/usage_records_list.json")
14+
request.return_value = resp
15+
16+
mock = Mock()
17+
mock.uri = "/base"
18+
account = Account(mock, 'AC123')
19+
account.load_subresources()
20+
records = account.usage_records.list()
21+
self.assertEquals(len(records), 2)
22+
23+
@patch("twilio.rest.resources.base.make_twilio_request")
24+
def test_usage_triggers_subresource(self, request):
25+
resp = create_mock_json("tests/resources/usage_triggers_list.json")
26+
request.return_value = resp
27+
28+
mock = Mock()
29+
mock.uri = "/base"
30+
account = Account(mock, 'AC123')
31+
account.load_subresources()
32+
triggers = account.usage_triggers.list()
33+
self.assertEquals(len(triggers), 2)

twilio/rest/resources/accounts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ConnectApps, AuthorizedConnectApps
1212
)
1313
from twilio.rest.resources.queues import Queues
14+
from twilio.rest.resources.usage import UsageRecords, UsageTriggers
1415

1516

1617
class Account(InstanceResource):
@@ -33,6 +34,8 @@ class Account(InstanceResource):
3334
ConnectApps,
3435
Queues,
3536
AuthorizedConnectApps,
37+
UsageRecords,
38+
UsageTriggers,
3639
]
3740

3841
def update(self, **kwargs):

0 commit comments

Comments
 (0)
0