Skip to content

Commit

Permalink
Added Travis CI and codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Dart committed Jul 24, 2020
1 parent d84075b commit b2bfad3
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: python
python:
- 2.7
- 3.8
install: pip install tox-travis
script: tox -v -c travis.tox.ini
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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.

Expand Down
18 changes: 9 additions & 9 deletions tests/fstestapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# tox config for local development. See also travis.tox.ini
[tox]
skipsdist = True
envlist=
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions travis.tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b2bfad3

Please sign in to comment.