~lifeless/python-oops-tools/prune

« back to all changes in this revision

Viewing changes to src/oopstools/oops/test/admin-pagetest.txt

  • Committer: Robert Collins
  • Date: 2011-10-13 20:18:51 UTC
  • Revision ID: robertc@robertcollins.net-20111013201851-ym8jmdhoeol3p83s
Export of cruft-deleted tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Django offers an admin interface to directly edit models.
 
2
 
 
3
    >>> from oopstools.oops import djangobrowser
 
4
    >>> from django.contrib.auth.models import User
 
5
 
 
6
    >>> user = User.objects.create_user(
 
7
    ...     'john', 'johndoe@example.com', 'test')
 
8
 
 
9
To access the admin interface, the user must be part of the staff (represented
 
10
by is_staff attribute) and to edit the models, user must be a super user.
 
11
 
 
12
    >>> user.is_superuser = True
 
13
    >>> user.is_staff = True
 
14
    >>> user.save()
 
15
 
 
16
    >>> b = djangobrowser.Browser()
 
17
 
 
18
Now let's open the admin page.
 
19
 
 
20
    >>> b.open('http://localhost/admin')
 
21
 
 
22
Log in.
 
23
 
 
24
    >>> b.getControl('Username').value = 'john'
 
25
    >>> b.getControl('Password').value = 'test'
 
26
    >>> b.getControl('Log in').click()
 
27
 
 
28
Browse to the Oops section of the admin site.
 
29
 
 
30
    >>> b.getLink('Oops').click()
 
31
 
 
32
    >>> b.url
 
33
    'http://localhost/admin/oops/'
 
34
 
 
35
    >>> print b.contents
 
36
    <...
 
37
    ...<h1>Oops administration</h1>
 
38
    ...