Skip to content

test_metax_user#

test_user_soft_delete#

Source code in tests/unit/apps/users/models/test_metax_user.py
@pytest.mark.django_db
def test_user_soft_delete(user):
    user.delete()
    searched_user = MetaxUser.objects.get(username=user.username)
    assert searched_user.is_removed is True

test_user_undelete#

When using undelete method

Metax user should return to available objects is_hidden param should set to False by default

Source code in tests/unit/apps/users/models/test_metax_user.py
@pytest.mark.django_db
def test_user_undelete(user):
    """When using undelete method

    Metax user should return to available objects
    is_hidden param should set to False by default
    """
    user.is_hidden = True
    user.save()
    user.undelete()
    searched_user = MetaxUser.available_objects.get(username=user.username)
    assert searched_user.is_removed is False
    assert searched_user.is_hidden is False

test_user_hard_delete#

Source code in tests/unit/apps/users/models/test_metax_user.py
@pytest.mark.django_db
def test_user_hard_delete(user):
    user.delete(soft=False)
    users = MetaxUser.objects.all()

    # check if metax technical user is created on other tests
    if len(users) == 1:
        assert MetaxUser.objects.all()[0].username == "metax"