Files
notifications-admin/tests/app/main/test_user.py
Chris Hill-Scott f3a0c505bd Enforce order and style of imports
Done using isort[1], with the following command:
```
isort -rc ./app ./tests
```

Adds linting to the `run_tests.sh` script to stop badly-sorted imports
getting re-introduced.

Chosen style is ‘Vertical Hanging Indent’ with trailing commas, because
I think it gives the cleanest diffs, eg:
```
from third_party import (
    lib1,
    lib2,
    lib3,
    lib4,
)
```

1. https://pypi.python.org/pypi/isort
2018-02-27 16:35:13 +00:00

33 lines
926 B
Python

import pytest
from app.notify_client.user_api_client import User
def test_user():
user_data = {'id': 1,
'name': 'Test User',
'email_address': 'test@user.gov.uk',
'mobile_number': '+4412341234',
'state': 'pending',
'failed_login_count': 0
}
user = User(user_data)
assert user.id == 1
assert user.name == 'Test User'
assert user.email_address == 'test@user.gov.uk'
assert user.mobile_number == '+4412341234'
assert user.state == 'pending'
# user has three failed logins before being locked
assert user.max_failed_login_count == 3
assert user.failed_login_count == 0
assert not user.is_locked()
# set failed logins to threshold
user.failed_login_count = 3
assert user.is_locked()
with pytest.raises(TypeError):
user.has_permissions('to_do_bad_things')