Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(18)  |  Call(16)  |  Derive(0)  |  Import(2)

src/d/j/django-contactme-1.1/django_contactme/tests/forms.py   django-contactme(Download)
import time
 
from django.test import TestCase
 
from django_contactme.forms import ContactMsgSecurityForm, ContactMsgForm
    def test_constructor(self):
        # timestamp and security_hash calculated during construction
        form = ContactMsgSecurityForm()
        self.assert_(form.initial.get("timestamp",     None) != None)
        self.assert_(form.initial.get("security_hash", None) != None)
        self.assert_(form.initial.get("honeypot",      None) == None)
 
        # even though they were provided as initial data
        initial = {'timestamp':'1122334455', 'security_hash':'blahblahashed'}
        form = ContactMsgSecurityForm(initial=initial.copy())
    def test_clean_timestamp(self):
        # check that a timestamp more than two hours old is not accepted
        form = ContactMsgSecurityForm()
        timestamp = int(form.initial["timestamp"]) - (2 * 60 * 61)
        security_hash = form.generate_security_hash(timestamp)
        data = {"timestamp":str(timestamp), "security_hash":security_hash}
        form = ContactMsgSecurityForm(data=data)

src/d/j/django-contactme-HEAD/django_contactme/tests/forms.py   django-contactme(Download)
import time
 
from django.test import TestCase
 
from django_contactme.forms import ContactMsgSecurityForm, ContactMsgForm
    def test_constructor(self):
        # timestamp and security_hash calculated during construction
        form = ContactMsgSecurityForm()
        self.assert_(form.initial.get("timestamp",     None) != None)
        self.assert_(form.initial.get("security_hash", None) != None)
        self.assert_(form.initial.get("honeypot",      None) == None)
 
        # even though they were provided as initial data
        initial = {'timestamp':'1122334455', 'security_hash':'blahblahashed'}
        form = ContactMsgSecurityForm(initial=initial.copy())
    def test_clean_timestamp(self):
        # check that a timestamp more than two hours old is not accepted
        form = ContactMsgSecurityForm()
        timestamp = int(form.initial["timestamp"]) - (2 * 60 * 61)
        security_hash = form.generate_security_hash(timestamp)
        data = {"timestamp":str(timestamp), "security_hash":security_hash}
        form = ContactMsgSecurityForm(data=data)