aurweb/test
Kevin Morris d5e650a339 add util.dedupe_qs -> dedupe_qs Jinja2 filter
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-19 09:53:59 -07:00
..
scripts Makefile: run pytest units 2021-06-05 19:49:19 -07:00
__init__.py aurweb: Globalize a Translator instance, add more utility 2021-06-05 19:49:42 -07:00
Makefile use mysql backend in config.dev 2021-06-05 20:17:48 -07:00
README.md add openssh to test dependencies 2021-06-05 20:11:17 -07:00
setup.sh Makefile: run pytest units 2021-06-05 19:49:19 -07:00
sharness.sh Upgrade Sharness to 1.1.0 2019-11-23 12:25:23 -05:00
t1100-git-auth.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
t1200-git-serve.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
t1300-git-update.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
t2100-mkpkglists.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
t2200-tuvotereminder.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
t2300-pkgmaint.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
t2400-aurblup.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
t2500-notify.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
t2600-rendercomment.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
t2700-usermaint.t Makefile: run pytest units 2021-06-05 19:49:19 -07:00
test_accepted_term.py use declarative_base for all ORM models 2021-06-10 13:54:27 -07:00
test_account_type.py use declarative_base for all ORM models 2021-06-10 13:54:27 -07:00
test_accounts_routes.py fix test_accounts_routes test coverage 2021-06-05 20:17:48 -07:00
test_api_rate_limit.py use mysql backend in config.dev 2021-06-05 20:17:48 -07:00
test_asgi.py add aurweb.db.session 2021-06-05 19:52:40 -07:00
test_auth.py remove unused imports, rectify isort violations 2021-06-05 21:27:39 -07:00
test_auth_routes.py Sanitize and modernize pytests 2021-06-05 20:11:17 -07:00
test_ban.py use mysql backend in config.dev 2021-06-05 20:17:48 -07:00
test_captcha.py add aurweb.captcha, a CAPTCHA utility module 2021-06-05 20:11:17 -07:00
test_config.py add aurweb.db.session 2021-06-05 19:52:40 -07:00
test_db.py aurweb.db: add commit(), add() and autocommit arg 2021-06-19 09:08:09 -07:00
test_dependency_type.py add DependencyType SQLAlchemy ORM model 2021-06-05 20:11:17 -07:00
test_exceptions.py Sanitize and modernize pytests 2021-06-05 20:11:17 -07:00
test_group.py Sanitize and modernize pytests 2021-06-05 20:11:17 -07:00
test_initdb.py use mysql backend in config.dev 2021-06-05 20:17:48 -07:00
test_l10n.py move aurweb.testing to its own package 2021-06-05 20:11:17 -07:00
test_license.py add License SQLAlchemy ORM model 2021-06-05 20:11:17 -07:00
test_official_provider.py add case [in]sensitivity tests + add OfficialProvider model 2021-06-05 23:20:18 -07:00
test_package.py use declarative_base for all ORM models 2021-06-10 13:54:27 -07:00
test_package_base.py add case [in]sensitivity tests + add OfficialProvider model 2021-06-05 23:20:18 -07:00
test_package_blacklist.py add PackageBlacklist SQLAlchemy ORM model 2021-06-11 17:28:08 -07:00
test_package_comaintainer.py test_package_comaintainer: sanitize newlines 2021-06-11 17:15:18 -07:00
test_package_comment.py add PackageComment SQLAlchemy ORM model 2021-06-11 00:35:18 -07:00
test_package_dependency.py add PackageDependency (PackageDepends) ORM model 2021-06-05 20:11:17 -07:00
test_package_group.py use declarative_base for all ORM models 2021-06-10 13:54:27 -07:00
test_package_keyword.py Sanitize and modernize pytests 2021-06-05 20:11:17 -07:00
test_package_license.py use declarative_base for all ORM models 2021-06-10 13:54:27 -07:00
test_package_notification.py add PackageNotification SQLAlchemy ORM model 2021-06-11 17:14:28 -07:00
test_package_relation.py use mysql backend in config.dev 2021-06-05 20:17:48 -07:00
test_package_request.py add PackageRequest SQLAlchemy ORM model 2021-06-11 21:21:38 -07:00
test_package_source.py add PackageSource SQLAlchemy ORM model 2021-06-10 17:46:29 -07:00
test_package_vote.py test_package_vote: remove useless stuff 2021-06-11 16:56:15 -07:00
test_popupdate.py add test_popupdate.py 2021-06-05 19:49:19 -07:00
test_relation_type.py add RelationType SQLAlchemy ORM model 2021-06-05 20:11:17 -07:00
test_request_type.py add RequestType SQLAlchemy ORM model 2021-06-11 17:37:51 -07:00
test_routes.py Sanitize and modernize pytests 2021-06-05 20:11:17 -07:00
test_session.py use declarative_base for all ORM models 2021-06-10 13:54:27 -07:00
test_ssh_pub_key.py add case [in]sensitivity tests + add OfficialProvider model 2021-06-05 23:20:18 -07:00
test_term.py Sanitize and modernize pytests 2021-06-05 20:11:17 -07:00
test_time.py add aurweb.time module 2021-06-05 20:11:17 -07:00
test_tu_vote.py add TUVote SQLAlchemy ORM model 2021-06-11 22:14:38 -07:00
test_tu_voteinfo.py TUVoteInfo: generalize Quorum 2021-06-11 21:48:39 -07:00
test_user.py add Base.as_dict() and Base.json() 2021-06-13 10:48:31 -07:00
test_util.py add util.dedupe_qs -> dedupe_qs Jinja2 filter 2021-06-19 09:53:59 -07:00

Running tests

To run all tests, you may run make check under test/ (alternative targets: make pytest, make sh).

For more control, you may use the prove or pytest command, which receives a directory or a list of files to run, and produces a report.

Each test script is standalone, so you may run them individually. Some tests may receive command-line options to help debugging. See for example sharness's documentation for shell test scripts: https://github.com/chriscool/sharness/blob/master/README.git

Dependencies

For all the test to run, the following Arch packages should be installed:

  • pyalpm
  • python-alembic
  • python-bleach
  • python-markdown
  • python-pygit2
  • python-sqlalchemy
  • python-srcinfo
  • python-coverage
  • python-pytest
  • python-pytest-cov
  • python-pytest-asyncio
  • postfix
  • openssh

Running tests

Recommended method of running tests: make check.

First, setup the test configuration:

$ sed -r 's;YOUR_AUR_ROOT;$(pwd);g' conf/config.dev > conf/config

You'll need to make sure that emails can be sent out by aurweb.scripts.notify. If you don't have anything setup, just install postfix and start it before running tests.

With those installed, one can run Python tests manually with any AUR config specified by AUR_CONFIG:

$ AUR_CONFIG=conf/config coverage run --append /usr/bin/pytest test/

After tests are run (particularly, with coverage run included), one can produce coverage reports.

# Print out a CLI coverage report.
$ coverage report
# Produce an HTML-based coverage report.
$ coverage html

When running make -C test, all tests ran will produce coverage data via coverage run --append. After running make -C test, one can continue with coverage reporting steps above. Running tests through make will test and cover code ran by both aurweb scripts and our pytest collection.

Writing tests

Shell test scripts must follow the Test Anything Protocol specification: http://testanything.org/tap-specification.html

Python tests must be compatible with pytest and included in pytest test/ execution after setting up a configuration.

Tests must support being run from any directory. They may use $0 to determine their location. Python scripts should expect aurweb to be installed and importable without toying with os.path or PYTHONPATH.

Tests written in shell should use sharness. In general, new tests should be consistent with existing tests unless they have a good reason not to.

Debugging tests

By default, make -C test is quiet and does not print out verbose information about tests being run. If a test is failing, one can look into verbose details of sharness tests by executing them with the --verbose flag. Example: ./t1100_git_auth.t --verbose. This is particularly useful when tests happen to fail in a remote continuous integration environment, where the reader does not have complete access to the runner.