django-testing

Using Basic HTTP access authentication in Django testing framework

Using Basic HTTP access authentication in Django testing framework Question: For some of my Django views I’ve created a decorator that performs Basic HTTP access authentication. However, while writing test cases in Django, it took me a while to work out how to authenticate to the view. Here’s how I did it. I hope somebody …

Total answers: 6

How do I modify the session in the Django test framework

How do I modify the session in the Django test framework Question: My site allows individuals to contribute content in the absence of being logged in by creating a User based on the current session_key I would like to setup a test for my view, but it seems that it is not possible to modify …

Total answers: 5

Testing email sending in Django

Testing email sending in Django Question: I need to test that my Django application sends e-mails with correct content. I don’t want to rely on external systems (like an ad-hoc gmail account), since I’m not testing the actual e-mail service… I would like to, maybe, store the emails locally, within a folder as they are …

Total answers: 10

How can I unit test django messages?

How can I unit test django messages? Question: In my django application, I’m trying to write a unit test that performs an action and then checks the messages in the response. As far as I can tell, there is no nice way of doing this. I’m using the CookieStorage storage method, and I’d like to …

Total answers: 7

Django test FileField using test fixtures

Django test FileField using test fixtures Question: I’m trying to build tests for some models that have a FileField. The model looks like this: class SolutionFile(models.Model): ”’ A file from a solution. ”’ solution = models.ForeignKey(Solution) file = models.FileField(upload_to=make_solution_file_path) I have encountered two problems: When saving data to a fixture using ./manage.py dumpdata, the file …

Total answers: 5

Writing good tests for Django applications

Writing good tests for Django applications Question: I’ve never written any tests in my life, but I’d like to start writing tests for my Django projects. I’ve read some articles about tests and decided to try to write some tests for an extremely simple Django app or a start. The app has two views (a …

Total answers: 2