Skip to content

Commit 5011fa0

Browse files
authored
Merge pull request #1212 from tethysplatform/switch-to-pytest
Migrate to Running Tests with Pytest
2 parents 58e8b34 + 98d2572 commit 5011fa0

File tree

59 files changed

+5601
-3170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+5601
-3170
lines changed

.github/workflows/tethys.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ jobs:
9292
conda activate tethys
9393
conda list
9494
tethys db start
95-
pip install coveralls reactpy_django
95+
pip install coveralls reactpy_django pytest pytest-django pytest-cov
9696
# Test Tethys
9797
- name: Test Tethys
9898
run: |
9999
. ~/miniconda/etc/profile.d/conda.sh
100100
conda activate tethys
101-
tethys test -c -u -v 2
101+
pytest
102102
# Generate Coverage Report
103103
- name: Generate Coverage Report
104104
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.10' && matrix.django-version == '4.2' }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ docs/_build
1616
tethys_gizmos/static/tethys_gizmos/less/bower_components/*
1717
node_modules
1818
.eggs/
19-
.coverage
19+
.coverage*
2020
tests/coverage_html_report
2121
.*.swp
2222
.DS_Store

docs/contribute/code/dev_environment.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Setting Up Development Environment
55
**********************************
66

7-
**Last Updated:** January 2025
7+
**Last Updated:** November 2025
88

99
The first step in contributing code to Tethys Platform is setting up a development environment. This guide will walk you through the process of setting up a development environment for Tethys Platform.
1010

@@ -108,7 +108,7 @@ Other Common Development Setups
108108
Use PostGIS Running in Docker
109109
-----------------------------
110110

111-
The most common use case for this setup is to run the test suite. Another common need for using a PostGIS database is to debug features related to Persistent Stores API.
111+
A common need for using a PostGIS database is to debug features related to Persistent Stores API or to better simulate a production environment. The following steps will guide you through setting up Tethys Platform to use a PostGIS database running in a Docker container.
112112

113113
.. warning::
114114

docs/contribute/code/testing.rst

Lines changed: 226 additions & 82 deletions
Large diffs are not rendered by default.

docs/tethys_sdk/extensions/models.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Extensions are not able to be linked to databases, but they can be used to store
2626
id = Column(Integer, autoincrement=True, primary_key=True)
2727
name = Column(String)
2828
description = Column(String)
29-
date_created = Column(DateTime, default=datetime.datetime.utcnow)
29+
date_created = Column(DateTime, default=datetime.datetime.now(datetime.UTC))
3030

3131

3232
To initialize the tables using a model defined in an extension, import the declarative base from the extension in the initializer function for the persistent store database you'd like to initialize:

docs/tethys_sdk/tethys_services/spatial_dataset_service/thredds_reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ This example is adapted from the `Siphon NCSS Time Series Example <https://unida
5151
5252
# Construct a query at a location specified by the latitude and longitude and time range
5353
# and return it in the NetCDF4 format
54-
now = datetime.utcnow()
54+
now = datetime.datetime.now(datetime.UTC)
5555
query.lonlat_point(-105, 40).time_range(now, now + timedelta(days=7))
5656
query.variables('streamflow').accept('netcdf')
5757

docs/tutorials/thredds/plot_at_location.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ In this step you will create a new controller that will query the dataset at the
197197
geometry(geojson): A geojson object representing the location.
198198
dataset(str): Name of the dataset to query.
199199
variable(str): Name of the variable to query.
200-
start_time(datetime): Start of time range to query. Defaults to datetime.utcnow().
200+
start_time(datetime): Start of time range to query. Defaults to datetime.datetime.now(datetime.UTC).
201201
end_time(datetime): End of time range to query. Defaults to 7 days after start_time.
202202
vertical_level(number): The vertical level to query. Defaults to 100000.
203203
@@ -215,7 +215,7 @@ In this step you will create a new controller that will query the dataset at the
215215
216216
# Filter by time
217217
if start_time is None:
218-
start_time = datetime.utcnow()
218+
start_time = datetime.datetime.now(datetime.UTC)
219219
220220
if end_time is None:
221221
end_time = start_time + timedelta(days=7)

pyproject.toml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ dependencies = [
4444
"django-guardian",
4545
]
4646

47+
[project.optional-dependencies]
48+
test = ["pytest", "pytest-django", "pytest-cov", "requests_mock"]
49+
lint = ["flake8", "black"]
50+
4751
[project.urls]
4852
homepage = "http://tethysplatform.org/"
4953
documentation = "http://docs.tethysplatform.org/en/stable/"
@@ -60,4 +64,22 @@ local_scheme = "no-local-version"
6064
include = ["tethys_*"]
6165

6266
[tool.setuptools]
63-
package-data = {"*" = ["*"]}
67+
package-data = {"*" = ["*"]}
68+
69+
[tool.pytest.ini_options]
70+
DJANGO_SETTINGS_MODULE = "tethys_portal.settings"
71+
addopts = "-s --cov"
72+
testpaths = ["tests/unit_tests/"]
73+
74+
[tool.coverage.run]
75+
omit = [
76+
"docs/*",
77+
"tests/*",
78+
"tethys_portal/_version.py",
79+
"tethys_portal/__init__.py",
80+
"*/migrations/*",
81+
]
82+
83+
[tool.coverage.report]
84+
show_missing = true
85+
skip_covered = true

0 commit comments

Comments
 (0)