def test_pin_ui(request): """View just for visually testing the pin UI. DEV ONLY. """ if not settings.TEMPLATE_DEBUG or not settings.DEBUG: return http.HttpResponseForbidden() form = forms.CreatePinForm() return render( request, 'pin/pin_form.html', { 'form': form, 'title': _('Create a Pin'), 'action': reverse('pin.create'), 'pin_form_tracking': { 'pin_error_codes': form.pin_error_codes, }, 'track_cancel': { 'action': 'pin cancel', 'label': 'Create Pin Page', } })
def test_has_pin(self): form = forms.CreatePinForm(uuid=self.uuid, data=self.data) assert not form.is_valid() assert getattr(form, 'buyer_exists', False) assert 'You have already created a PIN.' in str(form.errors) eq_(len(form.pin_error_codes), 1) eq_(form.pin_error_codes, ['PIN_ALREADY_CREATED'])
def test_html_form_attrs(self): form = forms.CreatePinForm(uuid=self.uuid, data=self.data) form_html = form.as_p() assert 'type="number"' in form_html assert 'autocomplete="off"' in form_html assert 'placeholder="****"' in form_html assert 'x-inputmode="digits"' in form_html assert 'max="9999"' in form_html
def test_dodgy(self, report): data = {'pin': chr(1)} forms.CreatePinForm(uuid=self.uuid, data=data) finished.send(None, request_meta={}, request_path='/') assert report.called
def test_too_long_pin(self): self.data.update({'pin': 'way too long pin'}) form = forms.CreatePinForm(uuid=self.uuid, data=self.data) assert not form.is_valid() assert 'has at most 4' in str(form.errors['pin'])
def test_existing_buyer(self): form = forms.CreatePinForm(uuid=self.uuid, data=self.data) assert form.is_valid(), form.errors assert getattr(form, 'buyer_exists', False)
def test_has_pin(self): form = forms.CreatePinForm(uuid=self.uuid, data=self.data) assert not form.is_valid() assert getattr(form, 'buyer_exists', False) assert 'You have already created a PIN.' in str(form.errors)
def test_has_pin(self): form = forms.CreatePinForm(uuid=self.uuid, data=self.data) assert not form.is_valid() eq_(len(form.pin_error_codes), 1) eq_(form.pin_error_codes, [msg.PIN_ALREADY_CREATED])
def test_existing_buyer(self): form = forms.CreatePinForm(uuid=self.uuid, data=self.data) assert form.is_valid(), form.errors