Builtin AutoFixture subclasses¶
There are some AutoFixture subclasses that are shipped by default with django-autofixture. They are listed below.
- class autofixture.autofixtures.UserFixture(*args, **kwargs)¶
UserFixture is automatically used by default to create new User instances. It uses the following values to assure that you can use the generated instances without any modification:
- username only contains chars that are allowed by django’s auth forms.
- email is unique.
- first_name and last_name are single, random words of the lorem ipsum text.
- is_staff and is_superuser are always False.
- is_active is always True.
- date_joined and last_login are always in the past and it is assured that date_joined will be lower than last_login.
- __init__(*args, **kwargs)¶
By default the password is set to an unusable value, this makes it impossible to login with the generated users. If you want to use for example autofixture.create_one('auth.User') in your unittests to have a user instance which you can use to login with the testing client you can provide a username and a password argument. Then you can do something like:
autofixture.create_one('auth.User', username='foo', password='bar`) self.client.login(username='foo', password='bar')