Django: Getting Started Transcripts
Chapter: Django Admin
Lecture: Testing with the Admin

Login or purchase this course to watch this video and the rest of the course contents.
0:00 It's wonderful that Django provides all this stuff. It means with very little code you have a full database management tool.
0:08 Although most of the code is Django's you are still writing some yourself. And when you write code you should write unit tests to go with it.
0:15 How do you do that? Well, let me walk you through it. First off, remember that you start with an empty test database.
0:24 That means your test suite will need to create a super user account programmatically. Otherwise you won't be able to log into the admin area.
0:32 The admin area is abstracted through a class called admin site. You can reference this inside of your tests in order to make calls to the admin area.
0:40 And if you're trying to test a customized field, the look up field shortcut will return you the value of a field as it would
0:49 be shown in the admins change list page. That means you don't have to parse the actual HTML from the view.
0:56 You can skip to just the part you want to test. Let's go write some tests.


Talk Python's Mastodon Michael Kennedy's Mastodon