Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
*.py[cod]
build/
dist/
\.coverage
labkey\.egg-info/
\.eggs/

# Project Artifacts
.idea/
*.iml
*.iml
*.swp
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,21 @@ LabKey Server v15.1 and later.
This package is maintained by [LabKey](http://www.labkey.com/). If you have any questions or need support, please use the [LabKey Server developer support forum](https://www.labkey.org/home/developer/forum/project-start.view).

### Testing
If you are looking to contribute please run the tests before issuing a PR. For now you need to manually get the dependencies:
If you are looking to contribute please run the tests before issuing a PR. The tests can be initiated by running

```bash
$ pip install mock
$ python setup.py test
```

Then, to run the tests:
This runs the tests using [pytest](https://docs.pytest.org/en/latest/contents.html). If you'd like to run pytest directly you can install the testing dependencies in your virtual environment with:

```bash
$ python test/test_labkey.py
$ pip install -e .[test]
```

Then, the tests can be run with
```bash
$ pytest .
```

### Maintainers
Expand Down
12 changes: 11 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
[metadata]
description-file = README.md
description-file = README.md

[aliases]
test=pytest

[tool:pytest]
addopts = -v --cov=labkey --cov-config=setup.cfg --cov-report=html --cov-report=term

[coverage:html]
directory = build/coverage_html
title = Test coverage report for labkey
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

long_desc = "Python client API for LabKey Server. Supports query and experiment APIs."

tests_require = ['pytest', 'requests', 'mock', 'pytest-cov']

setup(
name='labkey',
version=version,
Expand All @@ -50,7 +52,11 @@
packages=packages,
package_data={},
install_requires=['requests'],
tests_require=['requests', 'mock'],
tests_require=tests_require,
setup_requires=['pytest-runner'],
extras_require={
'test': tests_require
},
keywords="labkey api client",
classifiers=[
'Development Status :: 4 - Beta',
Expand Down
6 changes: 6 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from labkey import utils

# The mocks in the tests expect a request only to be made to the appropriate action.
# This flag disables the CSRF check built into ServerContext.make_request() so the tests
# get consistent results.
utils.DISABLE_CSRF_CHECK = True
2 changes: 1 addition & 1 deletion test/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from labkey.domain import create, Domain, drop, get, infer_fields, save
from labkey.exceptions import RequestAuthorizationError

from utilities import MockLabKey, mock_server_context, success_test, success_test_get, throws_error_test, throws_error_test_get
from .utilities import MockLabKey, mock_server_context, success_test, success_test_get, throws_error_test, throws_error_test_get


domain_controller = 'property'
Expand Down
2 changes: 1 addition & 1 deletion test/test_experiment_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from labkey.experiment import load_batch, save_batch, Batch, Run
from labkey.exceptions import RequestError, QueryNotFoundError, ServerNotFoundError, RequestAuthorizationError

from utilities import MockLabKey, mock_server_context, success_test, throws_error_test
from .utilities import MockLabKey, mock_server_context, success_test, throws_error_test


class MockLoadBatch(MockLabKey):
Expand Down
42 changes: 0 additions & 42 deletions test/test_labkey.py

This file was deleted.

2 changes: 1 addition & 1 deletion test/test_query_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from labkey.query import delete_rows, update_rows, insert_rows, select_rows, execute_sql, QueryFilter
from labkey.exceptions import RequestError, QueryNotFoundError, ServerNotFoundError, RequestAuthorizationError

from utilities import MockLabKey, mock_server_context, success_test, throws_error_test
from .utilities import MockLabKey, mock_server_context, success_test, throws_error_test


class MockSelectRows(MockLabKey):
Expand Down
2 changes: 1 addition & 1 deletion test/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
remove_from_group, remove_from_role, add_to_role, get_roles, list_groups
from labkey.exceptions import RequestError, QueryNotFoundError, ServerNotFoundError, RequestAuthorizationError

from utilities import MockLabKey, mock_server_context, success_test, throws_error_test
from .utilities import MockLabKey, mock_server_context, success_test, throws_error_test


class MockSecurityController(MockLabKey):
Expand Down
2 changes: 1 addition & 1 deletion test/test_unsupported.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from labkey import utils
from labkey.unsupported import messageboard

from utilities import MockLabKey, mock_server_context, success_test
from .utilities import MockLabKey, mock_server_context, success_test


class MockPostMessage(MockLabKey):
Expand Down