-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: - Add pytest framework on top of vanilla unittest - Set up necessary plumbing such as .tox and conftest.py - Update contributing and readme.md - Add read me for testing Test Plan: `tox` works, `py.test` works, `python setup.py test` works Reviewers: evan Differential Revision: https://work.r23s.net/D4624
- Loading branch information
yangchoo
committed
Apr 27, 2016
1 parent
d8d87c4
commit e0dbc90
Showing
12 changed files
with
66 additions
and
64 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[report] | ||
exclude_lines = | ||
pragma: no cover | ||
def __repr__ |
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,25 @@ | ||
# ![](https://www.transcriptic.com/images/logo-transcriptic-blobs-880e2f7b.svg) Transcriptic Python Library | ||
# Testing | ||
|
||
The Transcriptic Python Library (TxPy) provides a Python interface for managing Transcriptic organizations, projects, runs, datasets and more. | ||
One can either interface with our library through the bundled command line interface (CLI) or through a Jupyter notebook. | ||
## Overview | ||
|
||
We recommend using the Jupyter interface as it provides a nice rendering and presentation of the objects, as well as provide | ||
additional analysis and properties functions specific to the Transcriptic objects. | ||
We use the [pytest](http://pytest.org/latest/getting-started.html) framework for writing tests. A helpful resource for a | ||
list of supported assertions can be found [here](https://pytest.org/latest/assert.html). | ||
We also use [tox](https://tox.readthedocs.org/en/latest/) for automating tests. | ||
|
||
Transcriptic is the robotic cloud laboratory for the life sciences. [https://www.transcriptic.com](https://www.transcriptic.com) | ||
Ensure that all tests pass when you run `tox` in the main folder. | ||
Alternatively, one can run `py.test <path_to_test>` if you are trying to test a specific module. | ||
|
||
## Setup | ||
## Structure | ||
Helper functions should go into the helpers folder, and autoprotocol json in the autoprotocol folder. | ||
The `conftest.py` file contains any pytest related configurations. | ||
|
||
``` | ||
$ pip install transcriptic | ||
``` | ||
## Writing API Tests | ||
For API tests, we overwrite the base call command with a mock call that draws from the `mockDB` dictionary. | ||
To mock responses, we use the `MockResponse` class, which basically mirrors the `Response` class from the | ||
requests library. The three key fields to mock here are the `status_code`, `json` and `text` fields. | ||
Similar to the `Response` object, the `status_code` corresponds to the HTML response codes (e.g. 404, 201), | ||
the `json` method corresponds to the `json` response which is usually returned when the call is succesful. | ||
Lastly, the `text` field is what's commonly used for displaying logs/error messages. | ||
|
||
or | ||
The `api_test` module is a nice reference for how one typically sets up responses and test. | ||
|
||
``` | ||
$ git clone https://github.com/transcriptic/transcriptic.git | ||
$ cd transcriptic | ||
$ pip install . | ||
``` | ||
|
||
to upgrade to the latest version using pip or check whether you're already up to date: | ||
``` | ||
$ pip install transcriptic --upgrade | ||
``` | ||
|
||
Then, login to your Transcriptic account: | ||
|
||
``` | ||
$ transcriptic login | ||
Email: me@example.com | ||
Password: | ||
Logged in as me@example.com (example-lab) | ||
``` | ||
|
||
## Documentation | ||
|
||
See the [Transcriptic Developer Documentation](https://developers.transcriptic.com/docs/getting-started-with-the-cli) for detailed information about how to use this package, including learning about how to package protocols and build releases. | ||
|
||
View [developer specific documentation] (http://transcriptic.github.io/transcriptic/index.html) | ||
|
||
## Contributing | ||
|
||
Read CONTRIBUTING.mmd for more information on contributing to TxPy |
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
[wheel] | ||
universal = 1 | ||
|
||
[aliases] | ||
test=pytest | ||
|
||
[pytest] | ||
minversion = 2.3.3 | ||
python_files = "test/*_test.py" "test/test_*.py" | ||
python_classes = Test | ||
norecursedirs = ".tox" "build" "docs" |
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
File renamed without changes.
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import sys | ||
import os | ||
sys.path.append(os.path.join(os.path.dirname(__file__), 'helpers')) |
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
File renamed without changes.
File renamed without changes.
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
[tox] | ||
envlist = clean,py{27,35},stats | ||
envlist = clean, py{27,35}, stats | ||
|
||
[testenv] | ||
commands = | ||
coverage run --source transcriptic -a setup.py test | ||
deps = | ||
coverage | ||
pytest | ||
coverage | ||
pytest-cov | ||
|
||
commands = | ||
py.test --cov={envsitepackagesdir}/transcriptic --cov-report=term | ||
|
||
[testenv:clean] | ||
commands = | ||
coverage erase | ||
|
||
[testenv:stats] | ||
commands = | ||
coverage report -m --rcfile={toxinidir}/.coveragerc | ||
coverage report -m --rcfile={toxinidir}/.coveragerc |