vendredi 4 janvier 2019

What aspects of a function do I need to test?

I have the following build_settings_message function and I am a bit confused how should I write a unit test for it. What aspects of it do I need to check?

def build_settings_message(team_id):
    team = SlackTeam.objects.find_by_id(team_id)
    domain = Site.objects.get_current().domain

    attachments = [
        _build_manage_admins(),
        _build_checks_available(team, domain)
    ]

    return {
        'text': "Here is my settings page",
        'attachments': attachments
    }


def _build_manage_admins():
    return {
        "fallback": "Manage admins",
        "color": "#85cdff",
        "callback_id": "admins_controls",
        "title": "Admins",
        "footer": "Users that could remove and edit any checks ",
        "actions": [
            {
                "name": "manage",
                "text": ":key: Manage Admins",
                "type": "button",
                "value": "manage"
            }
        ]
    }


def _build_checks_available(team, domain):
    return {
        "title": "Items available",
        "footer": ("You have got *{} of {}* items for "
                   "check *available*.").format(
                       team.checks_used, team.checks_available),
        "actions": [
            {
                "text": "Open Dashboard",
                "type": "button",
                "url": 'https://' + domain + reverse('dashboard')
            }
        ]
    }

Aucun commentaire:

Enregistrer un commentaire