fabiocaccamo / django-maintenance-mode

:construction: :hammer_and_wrench: shows a 503 error page when maintenance-mode is on.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

change breaks compatibility and broke my tests

george-silva opened this issue · comments

Hi! Very nice project.

You made a recent change that broke my tests. For some reasons, they were not failing before, and MAINTENANCE_MODE was False.

Now, while testing, the MAINTENANCE_MODE is False and it picks up an IOError along the line, which makes the test fail.

This is most likely happening here: https://github.com/fabiocaccamo/django-maintenance-mode/blob/master/maintenance_mode/io.py#L12-L13

The function in core.py tries to convert this to an int, and fails. This is the traceback

ERROR: test_home (sistema.tests.test_context_processors.RegistroContextProcessorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/utils.py", line 196, in inner
    return test_func(*args, **kwargs)
  File "/builds/geoadmin/geoadmin/src/sistema/tests/test_context_processors.py", line 21, in test_home
    resposta = client.get(reverse('hotsite:home'))
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/client.py", line 500, in get
    **extra)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/client.py", line 303, in get
    return self.generic('GET', path, secure=secure, **r)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/client.py", line 379, in generic
    return self.request(**r)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/client.py", line 466, in request
    six.reraise(*exc_info)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 108, in get_response
    response = middleware_method(request)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/maintenance_mode/middleware.py", line 31, in process_request
    if settings.MAINTENANCE_MODE or core.get_maintenance_mode():
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/maintenance_mode/core.py", line 9, in get_maintenance_mode
    value = bool(int(value))
TypeError: int() argument must be a string or a number, not 'NoneType'

@george-silva thanks for the report, I just relased 0.5.1 and it should be fixed.
I added tests too. Let me know.

@george-silva have you tested 0.5.2 version? Is it ok?

Looks ok @fabiocaccamo . I haven't had the chance to test it, because I forked the repo when I found the bug, since I was needing it badly for an app in production.

We will have an update today or tomorrow and I'll let you know.

Thanks