stephenmcd / mezzanine

CMS framework for Django
http://mezzanine.jupo.org
BSD 2-Clause "Simplified" License
4.77k stars 1.64k forks source link

Task List: Tests that need to be written #1012

Open jerivas opened 10 years ago

jerivas commented 10 years ago

The reason for this list

As Mezzanine grows and expands to cover more and more use cases, every new commit has the potential of inadvertently breaking something somewhere in the code base.

This issue keeps track of the tests that need to be written to ensure certain features are not broken. The goal is to have a comprehensive test base to avoid nasty surprises on new releases.

If you contribute a new feature or fix a bug, please run the current tests, write some for your contributions and comment on this issue to have your tests added as completed. If you can't write the test, comment on this issue to have it added as pending. Lastly, you can contribute by tackling some of the pending tests of this list.

The list

Core

prikhi commented 10 years ago

I'm down for writing some tests. I've got a Django project going with 300 some tests.

Some resources for anybody that wants to help: http://test-driven-django-development.readthedocs.org/ http://chimera.labs.oreilly.com/books/1234000000754/index.html http://effectivedjango.com/orm.html#testing http://effectivedjango.com/forms.html#testing

To get a coverage report you can run:

pip install coverage
coverage run --branch --source="mezzanine" setup.py test
coverage report -m
coverage html

I'm not sure how accurate this is, so you should compare it to the tests for that module(I usually use nose and django-nose for testing Django apps/projects).

If we want to test everything thoroughly, some things might have to be refactored into smaller functions. For example, in mezzanine.utils.views.is_spam_akismet, we would have to separate the processing from the http request. Then we could test the processing without relying on being able to query akismet.

Anyways, I'll comb through a couple modules soon and post anything that needs more coverage.

jerivas commented 10 years ago

Thanks a lot @prikhi! Waiting for your contributions.

prikhi commented 10 years ago

I started with one of the easier modules, the blog app. I don't know how in-depth we want to get with these, some might be considered unnecessary, or very low priority.

I didn't go over the management commands, and I'll slowly work through everything else.

stephenmcd commented 10 years ago

That's a really good list.

jerivas commented 10 years ago

Great! I've added everything to the list and broken up tests by categories according to Mezzanine's internal structure.

prikhi commented 10 years ago

Galleries

auvipy commented 9 years ago

@stephenmcd having a mezzanine coverage report added on repo will be helpful

stephenmcd commented 9 years ago

Would you like to make that happen? That'd be great.

afs2015 commented 8 years ago

@stephenmcd: Does that coverage report still need to be added to the repo? If so I can make that happen.

prikhi commented 8 years ago

@afs2015 Looks like it to me. I'm guessing you mean Coveralls.io support? Because I'd wager the repository owner or a collaborator would have to activate the repo on Coveralls. Although you could get the travis.ci end setup.

spookylukey commented 7 years ago

For a lot of Mezzanine functionality, the testing tools provided by Django are inadequate. In particular, tests that use more than one HTTP request. The Django test client is basically useless for this - it doesn't simulate what browsers do closely enough to be of value.

For example, to test the login form changes I did in https://github.com/stephenmcd/mezzanine/pull/1737 you need to:

  1. Load the login page
  2. 'Click' the 'site' radio button
  3. Attempt to log in (with failed password)
  4. Ensure that the 'site' radio button is still active.

The tests need to be written at the same high level - otherwise if we use the Django client we have the double pain of tests that are very verbose, and are a very poor indicator that the code actually works.

For this kind of use case, I think you should look into django-webtest, and for anything that needs Javascript, Selenium. You could also use django-functest which attempts to wrap both of these into a usable API. (Disclaimer - django-functest is mainly my work, but has worked well for me on various projects, and has very high test coverage itself).

jerivas commented 4 years ago

@spookylukey reading your comment and exploring django-functest makes me angry! Why? Because I've wasted so much time writing low-level, boilerplate-filled tests for the past few years instead of using it, lol.

This is definitely something we want to incorporate into Mezzanine. Let me know if you're still interested in helping out with a test suite based on django-functest. I think it'll be specially helpful for the admin. For now I've added some key components we want to test to the issue description in light of some things we discovered on #1956

spookylukey commented 4 years ago

@jerivas as I'm no longer an active user of Mezzanine (I was using it mainly for a client), I'm very unlikely to get the time to contribute here. However, I'm still using django-functest in lots of projects, so if you need help with anything on that front let me know and I'll see what I can do. That includes any place where the docs are inadequate.