Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_createExpense_error(self, mockMakeRequest):
mockMakeRequest.return_value = '{"expenses":[],"errors":{"base":["An unknown error occurred. Please try again or contact support@splitwise.com if you experience repeated issues. Sorry for the trouble!"]}}' # noqa: E501
expense = Expense()
expense.setCost('10')
expense.setDescription("Testing")
user1 = ExpenseUser()
user1.setId(79774)
user1.setPaidShare('10.00')
user1.setOwedShare('2.0')
user2 = ExpenseUser()
user2.setId(281236)
user2.setPaidShare('0.00')
user2.setOwedShare('8.00')
users = []
users.append(user1)
users.append(user2)
expense.setUsers(users)
expenseRes, errors = self.sObj.createExpense(expense)
mockMakeRequest.assert_called_with(
"https://secure.splitwise.com/api/v3.0/create_expense", "POST",
{'cost': '10',
'description': 'Testing',
'users__0__user_id': 79774,
'users__0__paid_share': '10.00',
'users__0__owed_share': '2.0',
'users__1__user_id': 281236,
def test_createExpense_exception(self, mockMakeRequest):
mockMakeRequest.side_effect = Exception(
"Invalid response %s. Please check your consumer key and secret." % 404)
expense = Expense()
expense.setCost('10')
expense.setDescription("Testing")
user1 = ExpenseUser()
user1.setId(79774)
user1.setPaidShare('10.00')
user1.setOwedShare('2.0')
user2 = ExpenseUser()
user2.setId(281236)
user2.setPaidShare('0.00')
user2.setOwedShare('8.00')
users = []
users.append(user1)
users.append(user2)
expense.setUsers(users)
with self.assertRaises(Exception):
expenseRes, errors = self.sObj.createExpense(expense)
mockMakeRequest.assert_called_with(
"https://secure.splitwise.com/api/v3.0/create_expense", "POST",
{'cost': '10',
def test_createExpense_split_manually_success(self, mockMakeRequest):
mockMakeRequest.return_value = '{"expenses":[{"id":1010934284,"group_id":null,"friendship_id":null,"expense_bundle_id":null,"description":"Testing","repeats":false,"repeat_interval":"never","email_reminder":false,"email_reminder_in_advance":-1,"next_repeat":null,"details":null,"comments_count":0,"payment":false,"creation_method":null,"transaction_method":"offline","transaction_confirmed":false,"transaction_id":null,"cost":"10.0","currency_code":"SGD","repayments":[{"from":281236,"to":79774,"amount":"8.0"}],"date":"2020-06-24T08:14:07Z","created_at":"2020-06-24T08:14:07Z","created_by":{"id":79774,"first_name":"Naman","last_name":"Aggarwal","picture":{"medium":"https://splitwise.s3.amazonaws.com/uploads/user/avatar/79774/medium_mypic.jpg"},"custom_picture":true},"updated_at":"2020-06-24T08:14:07Z","updated_by":null,"deleted_at":null,"deleted_by":null,"category":{"id":18,"name":"General"},"receipt":{"large":null,"original":null},"users":[{"user":{"id":79774,"first_name":"Naman","last_name":"Aggarwal","picture":{"medium":"https://splitwise.s3.amazonaws.com/uploads/user/avatar/79774/medium_mypic.jpg"}},"user_id":79774,"paid_share":"10.0","owed_share":"2.0","net_balance":"8.0"},{"user":{"id":281236,"first_name":"Siddharth","last_name":"Goel","picture":{"medium":"https://splitwise.s3.amazonaws.com/uploads/user/avatar/281236/medium_f5fccc37-0a88-4519-9398-59c8c19b92aa.jpeg"}},"user_id":281236,"paid_share":"0.0","owed_share":"8.0","net_balance":"-8.0"}]}],"errors":{}}' # noqa: E501
expense = Expense()
expense.setCost('10')
expense.setDescription("Testing")
user1 = ExpenseUser()
user1.setId(79774)
user1.setPaidShare('10.00')
user1.setOwedShare('2.0')
user2 = ExpenseUser()
user2.setId(281236)
user2.setPaidShare('0.00')
user2.setOwedShare('8.00')
users = []
users.append(user1)
users.append(user2)
expense.setUsers(users)
expenseRes, errors = self.sObj.createExpense(expense)
mockMakeRequest.assert_called_with(
"https://secure.splitwise.com/api/v3.0/create_expense", "POST",
{'cost': '10',
'description': 'Testing',
def test_createExpense_exception(self, mockMakeRequest):
mockMakeRequest.side_effect = Exception(
"Invalid response %s. Please check your consumer key and secret." % 404)
expense = Expense()
expense.setCost('10')
expense.setDescription("Testing")
user1 = ExpenseUser()
user1.setId(79774)
user1.setPaidShare('10.00')
user1.setOwedShare('2.0')
user2 = ExpenseUser()
user2.setId(281236)
user2.setPaidShare('0.00')
user2.setOwedShare('8.00')
users = []
users.append(user1)
users.append(user2)
expense.setUsers(users)
with self.assertRaises(Exception):
expenseRes, errors = self.sObj.createExpense(expense)
mockMakeRequest.assert_called_with(
"https://secure.splitwise.com/api/v3.0/create_expense", "POST",
{'cost': '10',
'description': 'Testing',
'users__0__user_id': 79774,
'users__0__paid_share': '10.00',
'users__0__owed_share': '2.0',
def test_createExpense_error(self, mockMakeRequest):
mockMakeRequest.return_value = '{"expenses":[],"errors":{"base":["An unknown error occurred. Please try again or contact support@splitwise.com if you experience repeated issues. Sorry for the trouble!"]}}' # noqa: E501
expense = Expense()
expense.setCost('10')
expense.setDescription("Testing")
user1 = ExpenseUser()
user1.setId(79774)
user1.setPaidShare('10.00')
user1.setOwedShare('2.0')
user2 = ExpenseUser()
user2.setId(281236)
user2.setPaidShare('0.00')
user2.setOwedShare('8.00')
users = []
users.append(user1)
users.append(user2)
expense.setUsers(users)
expenseRes, errors = self.sObj.createExpense(expense)
mockMakeRequest.assert_called_with(
"https://secure.splitwise.com/api/v3.0/create_expense", "POST",
{'cost': '10',
'description': 'Testing',
def test_createExpense_split_manually_success(self, mockMakeRequest):
mockMakeRequest.return_value = '{"expenses":[{"id":1010934284,"group_id":null,"friendship_id":null,"expense_bundle_id":null,"description":"Testing","repeats":false,"repeat_interval":"never","email_reminder":false,"email_reminder_in_advance":-1,"next_repeat":null,"details":null,"comments_count":0,"payment":false,"creation_method":null,"transaction_method":"offline","transaction_confirmed":false,"transaction_id":null,"cost":"10.0","currency_code":"SGD","repayments":[{"from":281236,"to":79774,"amount":"8.0"}],"date":"2020-06-24T08:14:07Z","created_at":"2020-06-24T08:14:07Z","created_by":{"id":79774,"first_name":"Naman","last_name":"Aggarwal","picture":{"medium":"https://splitwise.s3.amazonaws.com/uploads/user/avatar/79774/medium_mypic.jpg"},"custom_picture":true},"updated_at":"2020-06-24T08:14:07Z","updated_by":null,"deleted_at":null,"deleted_by":null,"category":{"id":18,"name":"General"},"receipt":{"large":null,"original":null},"users":[{"user":{"id":79774,"first_name":"Naman","last_name":"Aggarwal","picture":{"medium":"https://splitwise.s3.amazonaws.com/uploads/user/avatar/79774/medium_mypic.jpg"}},"user_id":79774,"paid_share":"10.0","owed_share":"2.0","net_balance":"8.0"},{"user":{"id":281236,"first_name":"Siddharth","last_name":"Goel","picture":{"medium":"https://splitwise.s3.amazonaws.com/uploads/user/avatar/281236/medium_f5fccc37-0a88-4519-9398-59c8c19b92aa.jpeg"}},"user_id":281236,"paid_share":"0.0","owed_share":"8.0","net_balance":"-8.0"}]}],"errors":{}}' # noqa: E501
expense = Expense()
expense.setCost('10')
expense.setDescription("Testing")
user1 = ExpenseUser()
user1.setId(79774)
user1.setPaidShare('10.00')
user1.setOwedShare('2.0')
user2 = ExpenseUser()
user2.setId(281236)
user2.setPaidShare('0.00')
user2.setOwedShare('8.00')
users = []
users.append(user1)
users.append(user2)
expense.setUsers(users)
expenseRes, errors = self.sObj.createExpense(expense)
mockMakeRequest.assert_called_with(
"https://secure.splitwise.com/api/v3.0/create_expense", "POST",
{'cost': '10',
'description': 'Testing',
'users__0__user_id': 79774,
'users__0__paid_share': '10.00',
'users__0__owed_share': '2.0',
'users__1__user_id': 281236,