This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = spaces | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
class AccountMixin: | ||
def get_account(self): | ||
data, _, _ = self._make_request('get', '/users/%s/account' % self.user_id) | ||
return data | ||
return self._make_request('get', '/users/%s/account' % self.user_id)[0] | ||
|
||
def get_account_transactions(self, query=None): | ||
data, _, _ = self._make_request('get', '/users/%s/transactions' % self.user_id, params=query) | ||
return data | ||
return self._make_request('get', '/users/%s/account/transactions' % self.user_id, params=query)[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import unittest | ||
import six | ||
import requests | ||
import helpers | ||
if six.PY3: | ||
from unittest.mock import patch | ||
else: | ||
from mock import patch | ||
|
||
from bandwidth.catapult import Client | ||
|
||
class AccountTests(unittest.TestCase): | ||
def test_get_account(self): | ||
""" | ||
get_account() should return account data | ||
""" | ||
estimated_json=""" | ||
{"balance": "538.37250","accountType":"pre-pay"} | ||
""" | ||
with patch('requests.request', return_value = helpers.create_response(200, estimated_json)) as p: | ||
client = helpers.get_client() | ||
data = client.get_account() | ||
p.assert_called_with('get', 'https://api.catapult.inetwork.com/v1/users/userId/account', auth=helpers.AUTH) | ||
self.assertEqual('pre-pay', data['accountType']) | ||
|
||
def test_get_account_transactions(self): | ||
""" | ||
get_account_transactions() should return account transactions | ||
""" | ||
estimated_json=""" | ||
[{"id": "transactionId1", "time": "2013-02-21T13:39:09Z","amount": "0.00750","type": "charge","units": "1","productType": "sms-out","number": "1234567890"}] | ||
""" | ||
with patch('requests.request', return_value = helpers.create_response(200, estimated_json)) as p: | ||
client = helpers.get_client() | ||
data = client.get_account_transactions() | ||
p.assert_called_with('get', 'https://api.catapult.inetwork.com/v1/users/userId/account/transactions', auth=helpers.AUTH, params=None) | ||
self.assertEqual('transactionId1', data[0]['id']) |