Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
language: python | |||
|
|||
python: | |||
- "2.7" | |||
|
|||
install: | |||
- pip install -r requirements.txt --use-mirrors | |||
- pip install coverage coveralls | |||
|
|||
script: | |||
- coverage run --source=bootstrapform setup.py test | |||
|
|||
after_success: | |||
- coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,54 @@ | |||
import os | |||
import sys | |||
|
|||
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings' | |||
|
|||
parent = os.path.dirname(os.path.dirname( | |||
os.path.abspath(__file__))) | |||
|
|||
sys.path.insert(0, parent) | |||
|
|||
from unittest import TestCase | |||
from django.template import Template, Context | |||
from django.core.management import call_command | |||
from django import forms | |||
|
|||
|
|||
TEST_DIR = os.path.abspath(os.path.join(__file__, '..')) | |||
|
|||
|
|||
CHOICES = ( | |||
(0, 'Zero'), | |||
(1, 'One'), | |||
(2, 'Two'), | |||
) | |||
|
|||
class ExampleForm(forms.Form): | |||
char_field = forms.CharField() | |||
choice_field = forms.ChoiceField(choices=CHOICES) | |||
radio_choice = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect) | |||
multiple_choice = forms.MultipleChoiceField(choices=CHOICES) | |||
multiple_checkbox = forms.MultipleChoiceField(choices=CHOICES, widget=forms.CheckboxSelectMultiple) | |||
file_fied = forms.FileField() | |||
password_field = forms.CharField(widget=forms.PasswordInput) | |||
textarea = forms.CharField(widget=forms.Textarea) | |||
boolean_field = forms.BooleanField() | |||
|
|||
|
|||
class BootstrapTemplateTagTests(TestCase): | |||
def setUp(self): | |||
call_command('syncdb', interactive=False) | |||
|
|||
def test_bootstrap_tag(self): | |||
form = ExampleForm() | |||
|
|||
html = Template("{% load bootstrap %}{{ form|bootstrap }}").render(Context({'form': form})) | |||
|
|||
with open('/tmp/basic.html', 'w+') as f: | |||
f.write(html) | |||
|
|||
image = os.path.join('fixtures', 'basic.html') | |||
with open(os.path.join(TEST_DIR, image)) as f: | |||
content = f.read() | |||
|
|||
self.assertEqual(html, content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,210 @@ | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<div class="form-group"> | |||
|
|||
|
|||
<label class="control-label " for="id_char_field">Char field</label> | |||
|
|||
|
|||
<div class=" "> | |||
<input id="id_char_field" type="text" class=" form-control" name="char_field" /> | |||
|
|||
|
|||
|
|||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
|
|||
|
|||
|
|||
<div class="form-group"> | |||
|
|||
|
|||
<label class="control-label " for="id_choice_field">Choice field</label> | |||
|
|||
|
|||
<div class=" "> | |||
<select id="id_choice_field" class=" form-control" name="choice_field"> | |||
<option value="0">Zero</option> | |||
<option value="1">One</option> | |||
<option value="2">Two</option> | |||
</select> | |||
|
|||
|
|||
|
|||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
|
|||
|
|||
|
|||
<div class="form-group"> | |||
|
|||
|
|||
<label class="control-label ">Radio choice</label> | |||
|
|||
<div class=""> | |||
|
|||
<div class="radio"> | |||
<label> | |||
<input type="radio" name="radio_choice" value="0" /> | |||
Zero | |||
</label> | |||
</div> | |||
|
|||
<div class="radio"> | |||
<label> | |||
<input type="radio" name="radio_choice" value="1" /> | |||
One | |||
</label> | |||
</div> | |||
|
|||
<div class="radio"> | |||
<label> | |||
<input type="radio" name="radio_choice" value="2" /> | |||
Two | |||
</label> | |||
</div> | |||
|
|||
|
|||
|
|||
|
|||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
|
|||
|
|||
|
|||
<div class="form-group"> | |||
|
|||
|
|||
<label class="control-label " for="id_multiple_choice">Multiple choice</label> | |||
|
|||
|
|||
<div class=" "> | |||
<select multiple="multiple" id="id_multiple_choice" class=" form-control" name="multiple_choice"> | |||
<option value="0">Zero</option> | |||
<option value="1">One</option> | |||
<option value="2">Two</option> | |||
</select> | |||
|
|||
|
|||
|
|||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
|
|||
|
|||
|
|||
<div class="form-group"> | |||
|
|||
|
|||
<label class="control-label " for="id_multiple_checkbox">Multiple checkbox</label> | |||
|
|||
|
|||
<div class=" multiple-checkbox"> | |||
<ul> | |||
<li><label for="id_multiple_checkbox_0"><input type="checkbox" name="multiple_checkbox" value="0" id="id_multiple_checkbox_0" /> Zero</label></li> | |||
<li><label for="id_multiple_checkbox_1"><input type="checkbox" name="multiple_checkbox" value="1" id="id_multiple_checkbox_1" /> One</label></li> | |||
<li><label for="id_multiple_checkbox_2"><input type="checkbox" name="multiple_checkbox" value="2" id="id_multiple_checkbox_2" /> Two</label></li> | |||
</ul> | |||
|
|||
|
|||
|
|||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
|
|||
|
|||
|
|||
<div class="form-group"> | |||
|
|||
|
|||
<label class="control-label " for="id_file_fied">File fied</label> | |||
|
|||
|
|||
<div class=" "> | |||
<input type="file" name="file_fied" id="id_file_fied" /> | |||
|
|||
|
|||
|
|||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
|
|||
|
|||
|
|||
<div class="form-group"> | |||
|
|||
|
|||
<label class="control-label " for="id_password_field">Password field</label> | |||
|
|||
|
|||
<div class=" "> | |||
<input id="id_password_field" type="password" class=" form-control" name="password_field" /> | |||
|
|||
|
|||
|
|||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
|
|||
|
|||
|
|||
<div class="form-group"> | |||
|
|||
|
|||
<label class="control-label " for="id_textarea">Textarea</label> | |||
|
|||
|
|||
<div class=" "> | |||
<textarea id="id_textarea" rows="10" cols="40" name="textarea" class=" form-control"></textarea> | |||
|
|||
|
|||
|
|||
|
|||
</div> | |||
|
|||
</div> | |||
|
|||
|
|||
|
|||
|
|||
<div class="form-group"> | |||
|
|||
<div class=""> | |||
<div class="checkbox"> | |||
|
|||
<label > | |||
<input type="checkbox" name="boolean_field" id="id_boolean_field" /> <span>Boolean field</span> | |||
</label> | |||
|
|||
|
|||
|
|||
|
|||
</div> | |||
</div> | |||
|
|||
</div> | |||
|
|||
|
|||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
import os | |||
local_path = lambda path: os.path.join(os.path.dirname(__file__), path) | |||
|
|||
DATABASES = { | |||
'default': { | |||
'ENGINE': 'django.db.backends.sqlite3', | |||
'NAME': ':memory:' | |||
} | |||
} | |||
|
|||
SITE_ID = 1 | |||
|
|||
INSTALLED_APPS = [ | |||
'django.contrib.contenttypes', | |||
'django.contrib.sites', | |||
'django.contrib.sessions', | |||
'django.contrib.staticfiles', | |||
'django.contrib.auth', | |||
'django.contrib.admin', | |||
'bootstrapform', | |||
] | |||
|
|||
ROOT_URLCONF = 'tests.urls' | |||
|
|||
MEDIA_URL = '/media/' | |||
|
|||
MEDIA_ROOT = local_path('media') | |||
|
|||
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage' | |||
STATIC_ROOT = local_path('static/') | |||
STATIC_URL = '/static/' | |||
STATICFILES_FINDERS = ( | |||
'django.contrib.staticfiles.finders.FileSystemFinder', | |||
'django.contrib.staticfiles.finders.AppDirectoriesFinder' | |||
) | |||
|
|||
TEMPLATE_DIRS = ( | |||
local_path('templates'), | |||
) | |||
|