vendredi 28 décembre 2018

How to test a function which returns something and has side effect?

I have a function which returns something but has a side effect at the same time. Should I test only value which this function returns or I need to test result of a side effect too?

@slack_interactions.on('admin_add')
def handle_admin_add(payload):
    team_id = payload['team']['id']
    user_id = payload['user']['id']
    action_value = payload['actions'][0]['selected_options'][0]['value']

    user = SlackUser.objects.find_by_ids(team_id, action_value)

    if user and not user.is_bot:
        user.make_admin()

    return build_admins_message(team_id, user_id)

Aucun commentaire:

Enregistrer un commentaire