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_group_invalidkeys_fail(self):
sObj = Splitwise('consumerkey', 'consumersecret', {"oauth_token": "sdsd", "oauth_token_secret": "sdsdd"})
group = Group()
with self.assertRaises(SplitwiseUnauthorizedException):
sObj.createGroup(group)
def setUp(self):
self.sObj = Splitwise('consumerkey', 'consumersecret')
def setUp(self):
consumer_key = os.environ['CONSUMER_KEY']
consumer_secret = os.environ['CONSUMER_SECRET']
oauth_token = os.environ['OAUTH_TOKEN']
oauth_token_secret = os.environ['OAUTH_TOKEN_SECRET']
self.sObj = Splitwise(consumer_key, consumer_secret)
self.sObj.setAccessToken({'oauth_token': oauth_token, 'oauth_token_secret': oauth_token_secret})
def setUp(self):
self.sObj = Splitwise('consumerkey', 'consumersecret')
def setUp(self):
self.sObj = Splitwise('consumerkey', 'consumersecret')
def setUp(self):
self.sObj = Splitwise('consumerkey', 'consumersecret')
def setUp(self):
self.sObj = Splitwise('consumerkey', 'consumersecret')
def setUp(self):
self.sObj = Splitwise('consumerkey', 'consumersecret')
def test_createGroup_exception(self, mockMakeRequest):
mockMakeRequest.side_effect = Exception(
"Invalid response %s. Please check your consumer key and secret." % 404)
user = User()
user.setId(281236)
with self.assertRaises(Exception):
success, userRes, errors = self.sObj.addUserToGroup(user, 19481273)
mockMakeRequest.assert_called_with(
"https://secure.splitwise.com/api/v3.0/add_user_to_group", "POST",
{'group_id': 19481273, 'user_id': 281236})
def test_addUserToGroup_withid_success(self, mockMakeRequest):
mockMakeRequest.return_value = '{"success":true,"user":{"id":281236,"first_name":"Siddharth","last_name":"Goel","picture":{"small":"https://splitwise.s3.amazonaws.com/uploads/user/avatar/281236/small_f5fccc37-0a88-4519-9398-59c8c19b92aa.jpeg","medium":"https://splitwise.s3.amazonaws.com/uploads/user/avatar/281236/medium_f5fccc37-0a88-4519-9398-59c8c19b92aa.jpeg","large":"https://splitwise.s3.amazonaws.com/uploads/user/avatar/281236/large_f5fccc37-0a88-4519-9398-59c8c19b92aa.jpeg"},"custom_picture":true,"email":"siddharth98391@gmail.com","registration_status":"confirmed","balance":[]},"errors":{}}' # noqa: E501
user = User()
user.setId(281236)
success, userRes, errors = self.sObj.addUserToGroup(user, 19481273)
mockMakeRequest.assert_called_with(
"https://secure.splitwise.com/api/v3.0/add_user_to_group", "POST",
{'group_id': 19481273, 'user_id': 281236})
self.assertTrue(success)
self.assertIsNone(errors)
self.assertEqual(userRes.getId(), 281236)
self.assertEqual(userRes.getFirstName(), "Siddharth")
self.assertEqual(userRes.getLastName(), "Goel")
self.assertEqual(userRes.getPicture().getSmall(
), "https://splitwise.s3.amazonaws.com/uploads/user/avatar/281236/small_f5fccc37-0a88-4519-9398-59c8c19b92aa.jpeg")
self.assertEqual(userRes.getPicture().getMedium(
), "https://splitwise.s3.amazonaws.com/uploads/user/avatar/281236/medium_f5fccc37-0a88-4519-9398-59c8c19b92aa.jpeg")
self.assertEqual(userRes.getPicture().getLarge(
), "https://splitwise.s3.amazonaws.com/uploads/user/avatar/281236/large_f5fccc37-0a88-4519-9398-59c8c19b92aa.jpeg")