FinalsClub / karmaworld

KarmaNotes.org v3.0
GNU Affero General Public License v3.0
7 stars 6 forks source link

testing yields MessageFailures by the gallon #311

Open btbonval opened 10 years ago

btbonval commented 10 years ago

Bunch of MessageFailure errors while running python manage.py test. Not sure if this is from new code and should be ignored, or if this means all kinds of things will not run correctly.

I'm guessing someone forgot to add this to reqs: "django.contrib.messages.middleware.MessageMiddleware"?

Here's one for example:

ERROR:django.request:Internal Server Error: /add/error/
Traceback (most recent call last):
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/django/contrib/messages/tests/urls.py", line 30, in add
    getattr(messages, message_type)(request, msg)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/django/contrib/messages/api.py", line 102, in error
    fail_silently=fail_silently)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/django/contrib/messages/api.py", line 22, in add_message
    raise MessageFailure('You cannot add messages without installing '
MessageFailure: You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware
btbonval commented 10 years ago

This stackoverflow notes the same problem. The chosen answer is already done in the code properly. A secondary answer is this: http://stackoverflow.com/a/18160158/1867779

Suggests the order of MIDDLEWARE matters. We have a Csrf stuck in the middle. Not sure if that causes the problem or not.

btbonval commented 10 years ago

Another SO which looks a lot like our config having the same problem. No answers. http://stackoverflow.com/questions/15193545/django-contrib-messages-middleware-messagemiddleware-bug

charlesconnell commented 10 years ago

Weird. Never had this problem myself.

btbonval commented 10 years ago

Oh it's ye olde wrong test problem again. I thought there were a bit too many tests but I hadn't realized it when filing the ticket. It's running the south tests, not the unit tests. this time I installed all the dev stuff, too. Not sure why it can't find the right nosetest/coverage stuff from manage this time, but whatever.

Annoying that south and coverage are both aliasing to 'test'.

Closing as invalid.

btbonval commented 10 years ago

Yeah I cannot get django-nose to pop up on python manage.py at all, even though it is installed. The only real difference is a newer version of South, but I can't imagine why that'd cause south to more strongly take over the 'test' identifier.

The good news (for me) is that this is a known bug: http://south.aeracode.org/ticket/958

and someone wrote a little diddy to work around it when one's system refuses to work with the two packages nicely: https://gist.github.com/ErikEvenson/5455439

I copied that gist into a nosetest.py file under management/commands for local. Since no one else has the problem, I won't push this.

btbonval commented 10 years ago

crap even that gist is running south tests and not nose tests. I can't run just our tests using python manage stuff.

I'm not sure how to recursively search for tests under apps using nose. It always looks for tests in the current directory and recurses through that.

Whatever. Who needs testing? Ticket stays closed!

btbonval commented 9 years ago

This is still a problem for me, a year later, and with a new environment. @yourcelf updated tests, but I cannot run them. I'm reopening this ticket.

Additionally, we don't have testing documented in the README, which would be good to toss in somewhere. Make sure the environment works before deploying sort of thing.

This is my manage.py help output (look for south/test and django-nose/test):

Available subcommands:

[account]
    account_emailconfirmationmigration
    account_unsetmultipleprimaryemails

[auth]
    changepassword
    createsuperuser

[compressor]
    compress
    mtime_cache

[courses]
    dump_json
    fetch_usde_csv
    fix_note_counts
    import_json
    import_usde_csv
    sanitize_usde_schools

[django]
    cleanup 
    compilemessages
    createcachetable
    dbshell 
    diffsettings
    dumpdata
    flush   
    inspectdb
    loaddata
    makemessages
    runfcgi 
    shell   
    sql
    sqlall  
    sqlclear
    sqlcustom
    sqlflush
    sqlindexes
    sqlinitialdata
    sqlsequencereset
    startapp
    startproject
    validate

[djcelery]
    camqadm 
    celery  
    celerybeat
    celerycam
    celeryctl
    celeryd 
    celeryd_detach
    celeryd_multi
    celeryev
    celerymon
    djcelerymon

[gunicorn]
    run_gunicorn

[notes]
    add_canonical_link
    convert_notes_to_markdown
    import_ocw_json
    populate_filepicker
    populate_indexden
    regen_note_slugs
    strip_html_to_text
    tweet_note

[quizzes]
    get_mturk_results

[reversion]
    createinitialrevisions
    deleterevisions

[sessions]
    clearsessions

[south]
    convert_to_south
    datamigration
    graphmigrations
    migrate 
    migrationcheck
    schemamigration
    startmigration
    syncdb  
    test
    testserver

[staticfiles]
    collectstatic
    findstatic
    runserver