Skip to content

Commit

Permalink
Merge 68d3b23 into 623b753
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamu committed Jun 23, 2015
2 parents 623b753 + 68d3b23 commit 5a75138
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build/
django_test_plus.egg-info/
htmlcov/
.coverage
*.pyc
13 changes: 7 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ method makes it even easier::
def test_even_better_status(self):
response = self.get_check_200('my-url-name')

make\_user(username)
~~~~~~~~~~~~~~~~~~~~
make\_user(username, password='password')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When testing out views you often need to create various users to ensure
all of your logic is safe and sound. To make this process easier, this
Expand Down Expand Up @@ -237,8 +237,9 @@ To use a Factory Boy factory simply create your class like this::
def test_special_creation(self):
user1 = self.make_user('u1')

**NOTE:** Users created by this method will always have their password
set to the string 'password' in order to ease testing.
**NOTE:** Users created by this method will have their password
set to the string 'password' by default, in order to ease testing.
If you need a specific password simply override the ``password`` parameter.

Authentication Helpers
----------------------
Expand Down Expand Up @@ -277,8 +278,8 @@ restriction logic. This can be made easier with the following context::
# Test user2 see what they should be seeing

Since we're likely creating our users using ``make_user()`` from above,
we can assume the password is 'password' so the login context assumes
that for you as well, so you can do::
the login context assumes the password is 'password' unless specified
otherwise. Therefore you you can do::

def test_restrictions(self):
user1 = self.make_user('u1')
Expand Down
4 changes: 2 additions & 2 deletions test_plus/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ def get_check_200(self, url, *args, **kwargs):

def assertLoginRequired(self, url, *args, **kwargs):
""" Ensure login is required to GET this URL """
res = self.get(url, *args, **kwargs)
response = self.get(url, *args, **kwargs)
reversed_url = reverse(url, args=args, kwargs=kwargs)
expected_url = "{0}?next={1}".format(settings.LOGIN_URL, reversed_url)
self.assertRedirects(res, expected_url)
self.assertRedirects(response, expected_url)

def login(self, *args, **credentials):
""" Login a user """
Expand Down

0 comments on commit 5a75138

Please sign in to comment.