A
A
Artur Zenkov2016-10-21 10:42:25
Django
Artur Zenkov, 2016-10-21 10:42:25

How to test django?

To test, for example, view decorators and template tags, you have to move the decision-making logic into an external function so that you can lock the result.
(testing from SELENIUM)
Am I doing something wrong or is this the code being tested?
example:

def group_required(*group_names):
    """Requires user membership in at least one of the groups passed in."""
    def in_groups(user):
        groups = ['SMD-'+i for i in group_names]
        return has_access(user, groups)
    return user_passes_test(in_groups)


def has_access(user, groups):
    if user.groups.filter(name__in=groups).exists():
        return True
    else:
        raise PermissionDenied

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-10-21
@sim3x

Testing from selenium does not imply knowledge of the django code - check the reaction of the application to entering the page of the right user and the wrong one and see which page the application sends you to
If you need to track the behavior of code blocks, then use the unittest
stackoverflow.com/questions/2738641/testing-python ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question