From 06900320956c4abaddcf5ace636c4ae0519c39de Mon Sep 17 00:00:00 2001 From: Alex Zai Date: Sun, 22 Nov 2015 13:28:21 -0800 Subject: [PATCH] (fix) can handle no friends input --- src/venmo_api.py | 8 ++++---- tests/venmo_test.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/venmo_api.py b/src/venmo_api.py index 0da4332..1016b6f 100644 --- a/src/venmo_api.py +++ b/src/venmo_api.py @@ -118,10 +118,10 @@ def show_filtered_friends(cls, user_input): user_input, user inputted string in Alfred bar. """ - try: - friends = cls.findFriends(user_input) + friends = cls.findFriends(user_input) + if len(friends): cls.show_friends(friends) - except: + else: wf.add_item( title='No friends found', icon=ICON_WARNING) @@ -354,5 +354,5 @@ def generate_payload(cls, user_input, friend): 'user_id' : friend['id'], 'amount' : amount, 'note' : note, - 'display_name' : friend['display_name'] + 'display_name' : friend['display_name'] # for printing out name in push notification } diff --git a/tests/venmo_test.py b/tests/venmo_test.py index eb6fb2b..d15329e 100644 --- a/tests/venmo_test.py +++ b/tests/venmo_test.py @@ -6,7 +6,8 @@ import sys from src.config import LOGIN, LOGOUT, INVALID, CLEAR_CACHE -from src.venmo import main, wf +from src.venmo import main +from src.venmo_api import wf class TestVenmo(unittest.TestCase):