Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Oct 21, 2019
1 parent a01d94d commit 8b2451c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ cache: pip
install:
- set -e
- pip install --upgrade pip
- pip install pyflakes .
- pip install pyflakes pytest .
script:
- chartpress --version
- chartpress --help
- pyflakes .
- pytest -v ./tests

# This is a workaround to an issue caused by the existence of a docker
# registrymirror in our CI environment. Without this fix that removes the
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,19 @@ in your `.travis.yml`:
git:
depth: false
```

## Development

Testing of this python package can be done using [`pyflakes`](https://github.com/PyCQA/pyflakes) and [`pytest`](https://github.com/pytest-dev/pytest). There is also some additional testing that is only run as part of TravisCI, as declared in [`.travis.yml`](.travis.yml).

```
# install chartpress locally
pip install -e .

# install dev dependencies
pip install pyflakes pytest

# run tests
pyflakes .
pytest -v
```
Empty file added tests/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions tests/test_regexp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from chartpress import _strip_identifiers_build_suffix
from chartpress import _get_identifier

def test__strip_identifiers_build_suffix():
assert _strip_identifiers_build_suffix(identifier="0.1.2-005.asdf1234") == "0.1.2"
assert _strip_identifiers_build_suffix(identifier="0.1.2-alpha.1.005.asdf1234") == "0.1.2-alpha.1"

def test__get_identifier():
assert _get_identifier(tag="0.1.2", n_commits="0", commit="asdf123", long=True) == "0.1.2-000.asdf123"
assert _get_identifier(tag="0.1.2", n_commits="0", commit="asdf123", long=False) == "0.1.2"
assert _get_identifier(tag="0.1.2", n_commits="5", commit="asdf123", long=False) == "0.1.2-005.asdf123"
assert _get_identifier(tag="0.1.2-alpha.1", n_commits="0", commit="asdf1234", long=True) == "0.1.2-alpha.1.000.asdf1234"
assert _get_identifier(tag="0.1.2-alpha.1", n_commits="0", commit="asdf1234", long=False) == "0.1.2-alpha.1"
assert _get_identifier(tag="0.1.2-alpha.1", n_commits="5", commit="asdf1234", long=False) == "0.1.2-alpha.1.005.asdf1234"

0 comments on commit 8b2451c

Please sign in to comment.