Skip to content

Instantly share code, notes, and snippets.

@jherrlin
Created December 18, 2015 20:03
Show Gist options
  • Save jherrlin/e0861341dbb38af5c151 to your computer and use it in GitHub Desktop.
Save jherrlin/e0861341dbb38af5c151 to your computer and use it in GitHub Desktop.
Test after change of IPAddressField to GenericIPAddressField
py.test tests/ --cov admin_honeypot --cov-report term-missing --pep8 admin_honeypot
================================================================================ test session starts ================================================================================
platform darwin -- Python 2.7.10, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: /Users/nils/.virtualenvs/jherrlin-django1.9/lib/python2.7/site-packages/django-admin-honeypot, inifile: setup.cfg
plugins: cov-2.2.0, django-2.9.1, pep8-1.0.6
collected 17 items
tests/__init__.py .
tests/settings.py .
tests/test_suite.py .s..F.
tests/urls.py .
admin_honeypot/__init__.py .
admin_honeypot/admin.py .
admin_honeypot/forms.py .
admin_honeypot/listeners.py .
admin_honeypot/models.py .
admin_honeypot/signals.py .
admin_honeypot/urls.py .
admin_honeypot/views.py .
===================================================================================== FAILURES ======================================================================================
________________________________________________________________________ AdminHoneypotTest.test_same_content ________________________________________________________________________
self = <tests.test_suite.AdminHoneypotTest testMethod=test_same_content>
def test_same_content(self):
"""
The honeypot should be an exact replica of the admin login page,
with the exception of where the form submits to and the CSS to
hide the user tools.
"""
admin_html = self.client.get(self.admin_url, follow=True).content.decode('utf-8')
honeypot_html = self.client.get(self.honeypot_url, follow=True).content.decode('utf-8').replace(
'"{0}"'.format(self.honeypot_url),
'"{0}"'.format(self.admin_url)
)
> self.assertEqual(honeypot_html, admin_html)
E AssertionError: u'<!DOCTYPE html>\n\n<html lang="en-us" >\n<head>\n<title>Log in | Django site a [truncated]... != u'<!DOCTYPE html>\n\n<html lang="en-us" >\n<head>\n<title>Log in | Django site a [truncated]...
E <!DOCTYPE html>
E
E <html lang="en-us" >
E <head>
E <title>Log in | Django site admin</title>
E <link rel="stylesheet" type="text/css" href="/static/admin/css/base.css" />
E <link rel="stylesheet" type="text/css" href="/static/admin/css/login.css" />
E
E
E
E
E <meta name="robots" content="NONE,NOARCHIVE" />
E </head>
E
E
E <body class=" login"
E data-admin-utc-offset="0">
E
E <!-- Container -->
E <div id="container">
E
E
E <!-- Header -->
E <div id="header">
E <div id="branding">
E
E <h1 id="site-name"><a href="/secret/">Django administration</a></h1>
E
E </div>
E
E
E </div>
E <!-- END Header -->
E
E
E
E
E
E
E
E <!-- Content -->
E <div id="content" class="colM">
E
E
E
E
E
E
E
E <div id="content-main">
E
E
E
E <form action="/secret/login/" method="post" id="login-form"><input type='hidden' name='csrfmiddlewaretoken' value='CGVQiZjpyqEaDWmtr8tax8OSEqnmle34' />
E <div class="form-row">
E
E <label class="required" for="id_username">Username:</label> <input id="id_username" maxlength="254" name="username" type="text" />
E </div>
E <div class="form-row">
E
E <label class="required" for="id_password">Password:</label> <input id="id_password" name="password" type="password" />
E - <input type="hidden" name="next" value="/secret/login/" />
E ? ------
E + <input type="hidden" name="next" value="/secret/" />
E </div>
E
E
E <div class="submit-row">
E <label>&nbsp;</label><input type="submit" value="Log in" />
E </div>
E </form>
E
E <script type="text/javascript">
E document.getElementById('id_username').focus()
E </script>
E </div>
E
E
E <br class="clear" />
E </div>
E <!-- END Content -->
E
E <div id="footer"></div>
E </div>
E <!-- END Container -->
E
E </body>
E </html>
tests/test_suite.py:38: AssertionError
----------------------------------------------------------------- coverage: platform darwin, python 2.7.10-final-0 ------------------------------------------------------------------
Name Stmts Miss Cover Missing
-----------------------------------------------------------
admin_honeypot/__init__.py 5 0 100%
admin_honeypot/admin.py 30 9 70% 14-17, 20, 25, 30, 35, 38
admin_honeypot/forms.py 16 2 88% 28-30
admin_honeypot/listeners.py 14 0 100%
admin_honeypot/models.py 16 0 100%
admin_honeypot/signals.py 2 0 100%
admin_honeypot/urls.py 10 2 80% 6-7
admin_honeypot/views.py 34 1 97% 42
-----------------------------------------------------------
TOTAL 127 14 89%
================================================================== 1 failed, 15 passed, 1 skipped in 1.45 seconds ===================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment