def test_search_by_number(self, Boto3Resource): test_user = User() test_user.table.query.side_effect = lambda *a, **kw: { 'Items': ['MOCKED'] } u = test_user.search_by_number() assert u == [] u = test_user.search_by_number(phonenumber='XXXXXX') assert u == ['MOCKED'] test_user.table.query.assert_called_once()
def find_user(params): user_ph = params.get('From', None) if not user_ph: return UserStatus.NO_NUMBER, None u = User() user_ph = urllib.parse.unquote(user_ph) user_logs = u.search_by_number( phonenumber=user_ph, ) if not user_logs: u.create_row( phonenumber=user_ph, ) return UserStatus.NEW_USER, u return UserStatus.EXISTING_USER, u