diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..923e211 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: python +python: + - 2.7 + - 3.8 +install: pip install tox-travis +script: tox -v -c travis.tox.ini diff --git a/README.md b/README.md index a013956..ff47500 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# FormStorm (v1.0) +# FormStorm (v1.0) [![Build Status](https://travis-ci.org/TravisDart/formstorm.svg?branch=master)](https://travis-ci.org/TravisDart/formstorm) [![codecov](https://codecov.io/gh/TravisDart/formstorm/branch/master/graph/badge.svg)](https://codecov.io/gh/TravisDart/formstorm) + + FormStorm is a Python library that easily creates unit tests for Django forms. Given valid and invalid values for each field, the library computes every combination of the fields' values and submits them to the form. This validates all of the fields and tests for unintended interdependence between fields. In addition to testing single- and multi-field validation, FormStorm can also test single-field uniqueness constraints by double-submitting a valid submission and checking which fields become invalid on the 2nd submission. @@ -76,7 +78,7 @@ how you intend it to. ## Advanced Example: -An example showing how to use different field types can be found in [tests/fstestapp/test.py](tests/fstestapp/test.py). +An example showing how to use different field types can be found in [tests/fstestapp/tests.py](tests/fstestapp/tests.py). Basically, all fields work as above, with the exception of ForeignKey and Many2Many fields whose values must be specified with `Q()` objects. Also, example values for multi-valued fields (such as Many2Many) can be created with the `every_combo()` function which returns every combination of the Many2Many options. diff --git a/tests/fstestapp/tests.py b/tests/fstestapp/tests.py index 49af8f3..2eb8ada 100644 --- a/tests/fstestapp/tests.py +++ b/tests/fstestapp/tests.py @@ -11,37 +11,37 @@ class BookFormTest(FormTest): form = BookForm title = FormElement( good=["Moby Dick"], - bad=[None], # "", "A"*101], + bad=[None, "", "A"*101], is_unique=True ) subtitle = FormElement( - good=[None], # "", "or The Whale"], + good=[None, "", "or The Whale"], bad=["A"*101] ) author = FormElement( good=[Q(name="Herman Melville")], - bad=[None] # , "", -1] + bad=[None, "", -1] ) is_fiction = FormElement( - good=[True], # , False, None, "", -1, "A"], + good=[True, False, None, "", -1, "A"], bad=[] # Boolean input is either truthy or falsy, so nothing is bad. ) pages = FormElement( - good=[1], # , 10, 100], - bad=[None] # , "", "A"] + good=[0, 10, 100], + bad=[None, "", "A"] ) genre = FormElement( good=every_combo([ Q(name="Mystery"), Q(name="History"), - # Q(name="Humor") + Q(name="Humor") ]), bad=[None] ) additional_values = [ ({'title': "A"*100, 'subtitle': "A"*50}, True), - # ({'title': "A"*50, 'subtitle': "A"*100}, True), - # ({'title': "A"*100, 'subtitle': "A"*51}, False), + ({'title': "A"*50, 'subtitle': "A"*100}, True), + ({'title': "A"*100, 'subtitle': "A"*51}, False), ({'title': "A"*51, 'subtitle': "A"*100}, False), ] diff --git a/tox.ini b/tox.ini index e4fb164..ba33f7f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,3 +1,4 @@ +# tox config for local development. See also travis.tox.ini [tox] skipsdist = True envlist= @@ -22,7 +23,6 @@ commands = --rcfile={toxinidir}/.coveragerc \ --source='{toxinidir}/tests/,{toxinidir}/formstorm/' \ runtests.py -# coverage run --timid --branch --parallel-mode --source='{toxinidir}/tests/,{toxinidir}/formstorm/' runtests.py [testenv:end] deps = coverage diff --git a/travis.tox.ini b/travis.tox.ini new file mode 100644 index 0000000..f50e56e --- /dev/null +++ b/travis.tox.ini @@ -0,0 +1,22 @@ +# tox config for travis-ci. See also travis.tox.ini +[tox] +skipsdist = True +envlist= + py{27,38}-django111 + py38-django{22,30} + +[testenv] +passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_* +changedir = {toxinidir}/tests/ +deps = + coverage + codecov>=1.4.0 + django30: django==3.0.* + django22: django==2.2.* + django111: django==1.11.* +commands = + coverage run \ + --rcfile={toxinidir}/.coveragerc \ + --source='{toxinidir}/tests/,{toxinidir}/formstorm/' \ + runtests.py + codecov -e TOXENV