mirror of
https://github.com/andrewthetechie/py-healthchecks.io.git
synced 2025-12-05 17:18:16 +01:00
Compare commits
143 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78393be66b | ||
|
|
802520d454 | ||
|
|
97723e91b6 | ||
|
|
c56e048635 | ||
|
|
1f8449ca40 | ||
|
|
f94538951c | ||
|
|
b7438af127 | ||
|
|
d4b7849191 | ||
|
|
f785186582 | ||
|
|
f6aa9deeaf | ||
|
|
6de87bb43d | ||
|
|
4e0bf29e8a | ||
|
|
50f8bbabb2 | ||
|
|
ae3539a979 | ||
|
|
ef87bdb335 | ||
|
|
f8255292ef | ||
|
|
8214b5a5ac | ||
|
|
0f4119af47 | ||
|
|
7991cc15e6 | ||
|
|
1b14e4bdc8 | ||
|
|
778932a2f8 | ||
|
|
4ca01eaf0c | ||
|
|
d0b986025e | ||
|
|
cb862fa2c5 | ||
|
|
31218d3b00 | ||
|
|
2a1f45d7c0 | ||
|
|
c9b4a70948 | ||
|
|
5122e435f3 | ||
|
|
96f5d9cba9 | ||
|
|
47d763a201 | ||
|
|
f550ab0797 | ||
|
|
80ff5efc79 | ||
|
|
9b94d8d54e | ||
|
|
6c44d14c1a | ||
|
|
321828dfb6 | ||
|
|
095c8aa93e | ||
|
|
00251551d3 | ||
|
|
14f60a19bb | ||
|
|
b7eccfb74c | ||
|
|
fdfc51f399 | ||
|
|
e419d2b332 | ||
|
|
b52645068c | ||
|
|
7de885e2d4 | ||
|
|
2efc7fce99 | ||
|
|
a3cc535b85 | ||
|
|
fe6060d337 | ||
|
|
a748e07311 | ||
|
|
dac9c1e88b | ||
|
|
7570fc178c | ||
|
|
776e9fa194 | ||
|
|
83b7479021 | ||
|
|
3daa63f4fd | ||
|
|
1376595877 | ||
|
|
d3f26278c4 | ||
|
|
6c0b98b916 | ||
|
|
abda13198c | ||
|
|
b69f90390f | ||
|
|
9009f7456a | ||
|
|
e40540aa11 | ||
|
|
fb67bfc9ba | ||
|
|
8b6aebfc07 | ||
|
|
05226fab16 | ||
|
|
15ca0e757f | ||
|
|
6255bb5ad8 | ||
|
|
8ab99832ec | ||
|
|
cc8de4a2f7 | ||
|
|
1713780209 | ||
|
|
c644dc2827 | ||
|
|
e309911ce3 | ||
|
|
85b553ef83 | ||
|
|
15dbb47b6f | ||
|
|
12cba5e7ee | ||
|
|
d2e7f51cf3 | ||
|
|
ce2fef7edd | ||
|
|
62aecf60be | ||
|
|
296cf32d23 | ||
|
|
74e546c5e6 | ||
|
|
de6a7c388e | ||
|
|
fdacf0fc7a | ||
|
|
346a23f999 | ||
|
|
bf298304e7 | ||
|
|
bac7bbd4fc | ||
|
|
2b328d2caa | ||
|
|
7d076036d9 | ||
|
|
ef5141c9ee | ||
|
|
6bef6801e3 | ||
|
|
fcead223d8 | ||
|
|
2e205ba42f | ||
|
|
a0053b6bb4 | ||
|
|
8df036aef7 | ||
|
|
71ae85f101 | ||
|
|
c8ade5ff0d | ||
|
|
dd694b78dc | ||
|
|
37022b5cbe | ||
|
|
b6f2426f2e | ||
|
|
4edbe1740e | ||
|
|
55dc34db2e | ||
|
|
e5f49fc63c | ||
|
|
56ac786026 | ||
|
|
dd9cffe544 | ||
|
|
eeda043366 | ||
|
|
bfed9596f1 | ||
|
|
6fcff4f4ba | ||
|
|
986dd0a910 | ||
|
|
74f689f6f6 | ||
|
|
64cbeea5e9 | ||
|
|
c83b09592f | ||
|
|
30cff07ef0 | ||
|
|
1c7abdcef5 | ||
|
|
5750ebfc79 | ||
|
|
30b1e6d327 | ||
|
|
2a9fd649ca | ||
|
|
c6c9c63abf | ||
|
|
4b7eceaf48 | ||
|
|
72cb4eb159 | ||
|
|
351d5b2f41 | ||
|
|
425c6b44f0 | ||
|
|
dab7923e72 | ||
|
|
d74cde7805 | ||
|
|
b8b9939d9f | ||
|
|
b29ed0792f | ||
|
|
44f48c0817 | ||
|
|
0caf482172 | ||
|
|
5df0ddb040 | ||
|
|
286e262b75 | ||
|
|
672338a811 | ||
|
|
da4752088d | ||
|
|
21b27483ca | ||
|
|
7ca69b1c31 | ||
|
|
c607b04967 | ||
|
|
ffacdbc35c | ||
|
|
80cd50dc71 | ||
|
|
a8207c84e7 | ||
|
|
b91194cef9 | ||
|
|
de91dc95f7 | ||
|
|
4126125081 | ||
|
|
c6d7927ff0 | ||
|
|
6e1c830548 | ||
|
|
e0ec82c732 | ||
|
|
ecb16204f8 | ||
|
|
f2c2ea7a08 | ||
|
|
fbf5e480f7 | ||
|
|
e1404cd130 |
8
.github/dependabot.yml
vendored
8
.github/dependabot.yml
vendored
@@ -4,15 +4,23 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: daily
|
||||||
|
commit-message:
|
||||||
|
prefix: ci
|
||||||
- package-ecosystem: pip
|
- package-ecosystem: pip
|
||||||
directory: "/.github/workflows"
|
directory: "/.github/workflows"
|
||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: daily
|
||||||
|
commit-message:
|
||||||
|
prefix: ci
|
||||||
- package-ecosystem: pip
|
- package-ecosystem: pip
|
||||||
directory: "/docs"
|
directory: "/docs"
|
||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: daily
|
||||||
|
commit-message:
|
||||||
|
prefix: docs
|
||||||
- package-ecosystem: pip
|
- package-ecosystem: pip
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: daily
|
||||||
|
commit-message:
|
||||||
|
prefix: deps
|
||||||
|
|||||||
11
.github/workflows/constraints.txt
vendored
11
.github/workflows/constraints.txt
vendored
@@ -1,7 +1,6 @@
|
|||||||
pip==23.0.1
|
pip==24.0.0
|
||||||
nox==2022.11.21
|
nox==2024.4.15
|
||||||
nox-poetry==1.0.2
|
nox-poetry==1.0.3
|
||||||
poetry==1.3.2
|
poetry==1.8.2
|
||||||
virtualenv==20.19.0
|
virtualenv==20.26.1
|
||||||
poetry-dynamic-versioning==0.21.3
|
|
||||||
toml==0.10.2
|
toml==0.10.2
|
||||||
|
|||||||
2
.github/workflows/dependabot-auto-merge.yml
vendored
2
.github/workflows/dependabot-auto-merge.yml
vendored
@@ -7,7 +7,7 @@ jobs:
|
|||||||
auto-merge:
|
auto-merge:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: ahmadnassri/action-dependabot-auto-merge@v2
|
- uses: ahmadnassri/action-dependabot-auto-merge@v2
|
||||||
with:
|
with:
|
||||||
target: minor
|
target: minor
|
||||||
|
|||||||
4
.github/workflows/labeler.yml
vendored
4
.github/workflows/labeler.yml
vendored
@@ -10,9 +10,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the repository
|
- name: Check out the repository
|
||||||
uses: actions/checkout@v3.1.0
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Run Labeler
|
- name: Run Labeler
|
||||||
uses: crazy-max/ghaction-github-labeler@v4.1.0
|
uses: crazy-max/ghaction-github-labeler@v5.0.0
|
||||||
with:
|
with:
|
||||||
skip-delete: true
|
skip-delete: true
|
||||||
|
|||||||
6
.github/workflows/pre-release.yml
vendored
6
.github/workflows/pre-release.yml
vendored
@@ -10,12 +10,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the repository
|
- name: Check out the repository
|
||||||
uses: actions/checkout@v3.1.0
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4.5.0
|
uses: actions/setup-python@v5.1.0
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: "3.10"
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ jobs:
|
|||||||
poetry build --ansi
|
poetry build --ansi
|
||||||
|
|
||||||
- name: Publish package on TestPyPI
|
- name: Publish package on TestPyPI
|
||||||
uses: pypa/gh-action-pypi-publish@v1.6.4
|
uses: pypa/gh-action-pypi-publish@v1.8.14
|
||||||
with:
|
with:
|
||||||
user: __token__
|
user: __token__
|
||||||
password: ${{ secrets.TEST_PYPI_TOKEN }}
|
password: ${{ secrets.TEST_PYPI_TOKEN }}
|
||||||
|
|||||||
2
.github/workflows/release-please.yml
vendored
2
.github/workflows/release-please.yml
vendored
@@ -7,7 +7,7 @@ jobs:
|
|||||||
release-please:
|
release-please:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: google-github-actions/release-please-action@v3
|
- uses: google-github-actions/release-please-action@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.THIS_PAT }}
|
token: ${{ secrets.THIS_PAT }}
|
||||||
release-type: python
|
release-type: python
|
||||||
|
|||||||
31
.github/workflows/release.yml
vendored
31
.github/workflows/release.yml
vendored
@@ -8,32 +8,27 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
environment:
|
||||||
|
name: pypi
|
||||||
|
url: https://pypi.org/p/healthchecks-io
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the repository
|
- name: Check out the repository
|
||||||
uses: actions/checkout@v3.1.0
|
uses: actions/checkout@v4.1.4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4.5.0
|
uses: actions/setup-python@v5.1.0
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: "3.11"
|
||||||
|
- name: Install pip and poetry
|
||||||
- name: Upgrade pip
|
|
||||||
run: |
|
run: |
|
||||||
pip install --constraint=.github/workflows/constraints.txt pip
|
pip install --upgrade --constraint .github/workflows/constraints.txt pip poetry
|
||||||
pip --version
|
pip --version
|
||||||
|
|
||||||
- name: Install Poetry
|
|
||||||
run: |
|
|
||||||
pip install --constraint=.github/workflows/constraints.txt poetry poetry-dynamic-versioning
|
|
||||||
poetry --version
|
poetry --version
|
||||||
|
|
||||||
- name: Build package
|
- name: Build package
|
||||||
run: |
|
run: |
|
||||||
poetry build --ansi
|
poetry build
|
||||||
|
- name: Publish package distributions to PyPI
|
||||||
- name: Publish package on PyPI
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
uses: pypa/gh-action-pypi-publish@v1.6.4
|
|
||||||
with:
|
|
||||||
user: __token__
|
|
||||||
password: ${{ secrets.PYPI_TOKEN }}
|
|
||||||
|
|||||||
78
.github/workflows/tests.yml
vendored
78
.github/workflows/tests.yml
vendored
@@ -11,22 +11,15 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- { python: "3.10", os: "ubuntu-latest", session: "pre-commit" }
|
- { python: "3.11", os: "ubuntu-latest", session: "pre-commit" }
|
||||||
- { python: "3.10", os: "ubuntu-latest", session: "safety" }
|
- { python: "3.11", os: "ubuntu-latest", session: "safety" }
|
||||||
# - { python: "3.10", os: "ubuntu-latest", session: "mypy" }
|
- { python: "3.12", os: "ubuntu-latest", session: "tests" }
|
||||||
# - { python: "3.9", os: "ubuntu-latest", session: "mypy" }
|
|
||||||
# - { python: "3.8", os: "ubuntu-latest", session: "mypy" }
|
|
||||||
# - { python: "3.7", os: "ubuntu-latest", session: "mypy" }
|
|
||||||
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
|
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
|
||||||
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
|
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
|
||||||
- { python: "3.9", os: "ubuntu-latest", session: "tests" }
|
- { python: "3.9", os: "ubuntu-latest", session: "tests" }
|
||||||
- { python: "3.8", os: "ubuntu-latest", session: "tests" }
|
- { python: "3.8", os: "ubuntu-latest", session: "tests" }
|
||||||
- { python: "3.7", os: "ubuntu-latest", session: "tests" }
|
- { python: "3.11", os: "ubuntu-latest", session: "xdoctest" }
|
||||||
# poetry fails to install on windows
|
- { python: "3.11", os: "ubuntu-latest", session: "docs-build" }
|
||||||
# - { python: "3.10", os: "windows-latest", session: "tests" }
|
|
||||||
- { python: "3.11", os: "macos-latest", session: "tests" }
|
|
||||||
- { python: "3.10", os: "ubuntu-latest", session: "xdoctest" }
|
|
||||||
- { python: "3.10", os: "ubuntu-latest", session: "docs-build" }
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
NOXSESSION: ${{ matrix.session }}
|
NOXSESSION: ${{ matrix.session }}
|
||||||
@@ -35,37 +28,19 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the repository
|
- name: Check out the repository
|
||||||
uses: actions/checkout@v3.1.0
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python }}
|
- name: Set up Python ${{ matrix.python }}
|
||||||
uses: actions/setup-python@v4.5.0
|
uses: actions/setup-python@v5.1.0
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
|
|
||||||
- name: Upgrade pip
|
- name: Install needed tools
|
||||||
run: |
|
run: |
|
||||||
pip install --constraint=.github/workflows/constraints.txt pip
|
pip install --upgrade pip nox poetry virtualenv toml --constraint=.github/workflows/constraints.txt
|
||||||
pip --version
|
pip --version
|
||||||
|
# separate out nox-poetry until it gets a released version with support for 1.8
|
||||||
- name: Upgrade pip in virtual environments
|
pip install --upgrade nox-poetry --constraint=.github/workflows/constraints.txt
|
||||||
shell: python
|
|
||||||
run: |
|
|
||||||
import os
|
|
||||||
import pip
|
|
||||||
|
|
||||||
with open(os.environ["GITHUB_ENV"], mode="a") as io:
|
|
||||||
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
|
|
||||||
|
|
||||||
- name: Install Poetry
|
|
||||||
run: |
|
|
||||||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
|
|
||||||
poetry --version
|
|
||||||
|
|
||||||
- name: Install Nox
|
|
||||||
run: |
|
|
||||||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
|
|
||||||
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry toml
|
|
||||||
nox --version
|
|
||||||
|
|
||||||
- name: Compute pre-commit cache key
|
- name: Compute pre-commit cache key
|
||||||
if: matrix.session == 'pre-commit'
|
if: matrix.session == 'pre-commit'
|
||||||
@@ -85,7 +60,7 @@ jobs:
|
|||||||
fh.write(f"result={result}\n")
|
fh.write(f"result={result}\n")
|
||||||
|
|
||||||
- name: Restore pre-commit cache
|
- name: Restore pre-commit cache
|
||||||
uses: actions/cache@v3.2.5
|
uses: actions/cache@v4.0.2
|
||||||
if: matrix.session == 'pre-commit'
|
if: matrix.session == 'pre-commit'
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pre-commit
|
path: ~/.cache/pre-commit
|
||||||
@@ -96,32 +71,3 @@ jobs:
|
|||||||
- name: Run Nox
|
- name: Run Nox
|
||||||
run: |
|
run: |
|
||||||
nox --force-color --python=${{ matrix.python }}
|
nox --force-color --python=${{ matrix.python }}
|
||||||
|
|
||||||
- name: Upload coverage data
|
|
||||||
if: always() && matrix.session == 'tests'
|
|
||||||
uses: "actions/upload-artifact@v3.1.2"
|
|
||||||
with:
|
|
||||||
name: coverage-data
|
|
||||||
path: ".coverage.*"
|
|
||||||
|
|
||||||
- name: Upload documentation
|
|
||||||
if: matrix.session == 'docs-build'
|
|
||||||
uses: actions/upload-artifact@v3.1.2
|
|
||||||
with:
|
|
||||||
name: docs
|
|
||||||
path: docs/_build
|
|
||||||
|
|
||||||
coverage:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: tests
|
|
||||||
steps:
|
|
||||||
- name: Download coverage data
|
|
||||||
uses: actions/download-artifact@v3.0.2
|
|
||||||
with:
|
|
||||||
name: coverage-data
|
|
||||||
|
|
||||||
- name: Upload coverage report
|
|
||||||
uses: codecov/codecov-action@v3.1.1
|
|
||||||
with:
|
|
||||||
files: .coverage.xml
|
|
||||||
verbose: true
|
|
||||||
|
|||||||
@@ -1,11 +1,26 @@
|
|||||||
|
exclude: ".*tests\/fixtures.*"
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
# Ruff version.
|
rev: v4.6.0
|
||||||
rev: "v0.0.249"
|
|
||||||
hooks:
|
hooks:
|
||||||
|
- id: check-yaml
|
||||||
|
- id: debug-statements
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
|
# Ruff version.
|
||||||
|
rev: v0.4.3
|
||||||
|
hooks:
|
||||||
|
# Run the linter.
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [--fix, --exit-non-zero-on-fix]
|
args: [ --fix ]
|
||||||
types: [python]
|
# Run the formatter.
|
||||||
|
- id: ruff-format
|
||||||
|
- repo: https://github.com/rhysd/actionlint
|
||||||
|
rev: v1.6.27
|
||||||
|
hooks:
|
||||||
|
- id: actionlint-docker
|
||||||
|
name: Actionlint
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: bandit
|
- id: bandit
|
||||||
@@ -14,7 +29,7 @@ repos:
|
|||||||
language: system
|
language: system
|
||||||
types: [python]
|
types: [python]
|
||||||
require_serial: true
|
require_serial: true
|
||||||
args: ["-c", "bandit.yml"]
|
args: ["-c", "pyproject.toml"]
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
name: Check for added large files
|
name: Check for added large files
|
||||||
entry: check-added-large-files
|
entry: check-added-large-files
|
||||||
@@ -41,24 +56,10 @@ repos:
|
|||||||
entry: pyupgrade
|
entry: pyupgrade
|
||||||
language: system
|
language: system
|
||||||
types: [python]
|
types: [python]
|
||||||
args: [--py37-plus]
|
args: [--py38-plus]
|
||||||
- id: reorder-python-imports
|
|
||||||
name: Reorder python imports
|
|
||||||
entry: reorder-python-imports
|
|
||||||
language: system
|
|
||||||
types: [python]
|
|
||||||
args: [--application-directories=src]
|
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
name: Trim Trailing Whitespace
|
name: Trim Trailing Whitespace
|
||||||
entry: trailing-whitespace-fixer
|
entry: trailing-whitespace-fixer
|
||||||
language: system
|
language: system
|
||||||
types: [text]
|
types: [text]
|
||||||
stages: [commit, push, manual]
|
stages: [commit, push, manual]
|
||||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
||||||
rev: v2.7.1
|
|
||||||
hooks:
|
|
||||||
- id: prettier
|
|
||||||
- repo: https://github.com/rhysd/actionlint
|
|
||||||
rev: v1.6.15
|
|
||||||
hooks:
|
|
||||||
- id: actionlint-docker
|
|
||||||
|
|||||||
34
CHANGELOG.md
34
CHANGELOG.md
@@ -1,5 +1,39 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.4.2](https://github.com/andrewthetechie/py-healthchecks.io/compare/v0.4.1...v0.4.2) (2024-05-07)
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* bump croniter from 1.4.1 to 2.0.5 ([#660](https://github.com/andrewthetechie/py-healthchecks.io/issues/660)) ([f945389](https://github.com/andrewthetechie/py-healthchecks.io/commit/f94538951c0aed4b0528974d6cb29c4cfd859845))
|
||||||
|
* bump pytest-cov from 4.1.0 to 5.0.0 ([#663](https://github.com/andrewthetechie/py-healthchecks.io/issues/663)) ([802520d](https://github.com/andrewthetechie/py-healthchecks.io/commit/802520d4548d70e5597321e02b8d11af322431bd))
|
||||||
|
* bump safety from 2.3.5 to 3.2.0 ([#661](https://github.com/andrewthetechie/py-healthchecks.io/issues/661)) ([c56e048](https://github.com/andrewthetechie/py-healthchecks.io/commit/c56e048635d32eb9cf5c4f82a9929e9065da5735))
|
||||||
|
* bump sphinx from 5.3.0 to 7.1.2 ([#662](https://github.com/andrewthetechie/py-healthchecks.io/issues/662)) ([97723e9](https://github.com/andrewthetechie/py-healthchecks.io/commit/97723e91b631e3c4266a090e169eb19ffe1de153))
|
||||||
|
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
* bump furo from 2024.4.27 to 2024.5.6 in /docs ([#665](https://github.com/andrewthetechie/py-healthchecks.io/issues/665)) ([b7438af](https://github.com/andrewthetechie/py-healthchecks.io/commit/b7438af1275ce8fceb5d996aabd28cce5ca1193c))
|
||||||
|
|
||||||
|
## [0.4.1](https://github.com/andrewthetechie/py-healthchecks.io/compare/v0.4.0...v0.4.1) (2024-05-05)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* update poetry and virtualenv ([#489](https://github.com/andrewthetechie/py-healthchecks.io/issues/489)) ([1376595](https://github.com/andrewthetechie/py-healthchecks.io/commit/1376595877577848e0672d88403dc5740e7c1664))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* bump pytest-asyncio from 0.21.2 to 0.23.6 ([#657](https://github.com/andrewthetechie/py-healthchecks.io/issues/657)) ([f785186](https://github.com/andrewthetechie/py-healthchecks.io/commit/f7851865821ed0f6df4d4977a4e3a5bc26bbf190))
|
||||||
|
* bump ruff from 0.0.275 to 0.4.3 ([#655](https://github.com/andrewthetechie/py-healthchecks.io/issues/655)) ([6de87bb](https://github.com/andrewthetechie/py-healthchecks.io/commit/6de87bb43d2c236f1be762d439998baea5d0c417))
|
||||||
|
* bump types-croniter from 1.4.0.1 to 2.0.0.20240423 ([#654](https://github.com/andrewthetechie/py-healthchecks.io/issues/654)) ([50f8bba](https://github.com/andrewthetechie/py-healthchecks.io/commit/50f8bbabb2df6aed0931ca5979792e694121650c))
|
||||||
|
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
* fixes get_check args ([#597](https://github.com/andrewthetechie/py-healthchecks.io/issues/597)) ([cb862fa](https://github.com/andrewthetechie/py-healthchecks.io/commit/cb862fa2c576b62dee2661a2939f69548726bc11))
|
||||||
|
|
||||||
## [0.4.0](https://github.com/andrewthetechie/py-healthchecks.io/compare/v0.3.1...v0.4.0) (2023-02-21)
|
## [0.4.0](https://github.com/andrewthetechie/py-healthchecks.io/compare/v0.3.1...v0.4.0) (2023-02-21)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Sphinx configuration."""
|
"""Sphinx configuration."""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
furo==2022.12.7
|
furo==2024.5.6
|
||||||
sphinx==6.1.3
|
sphinx==7.3.7
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ Getting a Check
|
|||||||
|
|
||||||
client = Client(api_key="myapikey")
|
client = Client(api_key="myapikey")
|
||||||
|
|
||||||
check = client.get_check(uuid="mychecksuuid")
|
check = client.get_check(check_id="mychecksuuid")
|
||||||
print(check)
|
print(check)
|
||||||
|
|
||||||
Pinging a Check
|
Pinging a Check
|
||||||
|
|||||||
42
noxfile.py
42
noxfile.py
@@ -1,4 +1,5 @@
|
|||||||
"""Nox sessions."""
|
"""Nox sessions."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
@@ -23,28 +24,17 @@ except ImportError:
|
|||||||
|
|
||||||
|
|
||||||
package = "healthchecks_io"
|
package = "healthchecks_io"
|
||||||
python_versions = ["3.10", "3.11", "3.9", "3.8", "3.7"]
|
python_versions = ["3.11", "3.12", "3.10", "3.9", "3.8"]
|
||||||
nox.needs_version = ">= 2021.6.6"
|
nox.needs_version = ">= 2021.6.6"
|
||||||
nox.options.sessions = (
|
nox.options.sessions = (
|
||||||
"pre-commit",
|
"pre-commit",
|
||||||
"bandit",
|
|
||||||
"safety",
|
"safety",
|
||||||
"mypy",
|
# "mypy",
|
||||||
"tests",
|
"tests",
|
||||||
# "typeguard",
|
|
||||||
"xdoctest",
|
"xdoctest",
|
||||||
"docs-build",
|
"docs-build",
|
||||||
)
|
)
|
||||||
mypy_type_packages = ("types-croniter", "types-pytz")
|
|
||||||
test_requirements = (
|
|
||||||
"coverage[toml]",
|
|
||||||
"pytest",
|
|
||||||
"pygments",
|
|
||||||
"respx",
|
|
||||||
"pytest-asyncio",
|
|
||||||
"pytest-lazy-fixture",
|
|
||||||
)
|
|
||||||
mypy_type_packages = ()
|
|
||||||
pyproject = toml.load("pyproject.toml")
|
pyproject = toml.load("pyproject.toml")
|
||||||
test_requirements = pyproject["tool"]["poetry"]["group"]["dev"]["dependencies"].keys()
|
test_requirements = pyproject["tool"]["poetry"]["group"]["dev"]["dependencies"].keys()
|
||||||
|
|
||||||
@@ -118,20 +108,7 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
|
|||||||
def precommit(session: Session) -> None:
|
def precommit(session: Session) -> None:
|
||||||
"""Lint using pre-commit."""
|
"""Lint using pre-commit."""
|
||||||
args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"]
|
args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"]
|
||||||
session.install(
|
session.install(*test_requirements)
|
||||||
"black",
|
|
||||||
"darglint",
|
|
||||||
"flake8",
|
|
||||||
"flake8-bandit",
|
|
||||||
"flake8-bugbear",
|
|
||||||
"flake8-docstrings",
|
|
||||||
"flake8-rst-docstrings",
|
|
||||||
"pep8-naming",
|
|
||||||
"pre-commit",
|
|
||||||
"pre-commit-hooks",
|
|
||||||
"pyupgrade",
|
|
||||||
"reorder-python-imports",
|
|
||||||
)
|
|
||||||
session.run("pre-commit", *args)
|
session.run("pre-commit", *args)
|
||||||
if args and args[0] == "install":
|
if args and args[0] == "install":
|
||||||
activate_virtualenv_in_precommit_hooks(session)
|
activate_virtualenv_in_precommit_hooks(session)
|
||||||
@@ -153,17 +130,10 @@ def mypy(session: Session) -> None:
|
|||||||
args = session.posargs or ["src"]
|
args = session.posargs or ["src"]
|
||||||
session.install(".")
|
session.install(".")
|
||||||
session.install("mypy", "pytest")
|
session.install("mypy", "pytest")
|
||||||
session.install(*mypy_type_packages)
|
session.install(*test_requirements)
|
||||||
session.run("mypy", *args)
|
session.run("mypy", *args)
|
||||||
|
|
||||||
|
|
||||||
@session(python=python_versions[0])
|
|
||||||
def bandit(session: Session) -> None:
|
|
||||||
"""Run bandit security tests"""
|
|
||||||
args = session.posargs or ["-r", "./src"]
|
|
||||||
session.run("bandit", *args)
|
|
||||||
|
|
||||||
|
|
||||||
@session(python=python_versions)
|
@session(python=python_versions)
|
||||||
def tests(session: Session) -> None:
|
def tests(session: Session) -> None:
|
||||||
"""Run the test suite."""
|
"""Run the test suite."""
|
||||||
|
|||||||
1863
poetry.lock
generated
1863
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "healthchecks_io"
|
name = "healthchecks_io"
|
||||||
version = "0.4.0"
|
version = "0.4.2"
|
||||||
description = "A python client package for Healthchecks.io API"
|
description = "A python client package for Healthchecks.io API"
|
||||||
authors = ["Andrew Herrington <andrew.the.techie@gmail.com>"]
|
authors = ["Andrew Herrington <andrew.the.techie@gmail.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@@ -25,34 +25,34 @@ classifiers = [
|
|||||||
Changelog = "https://github.com/andrewthetechie/py-healthchecks.io/releases"
|
Changelog = "https://github.com/andrewthetechie/py-healthchecks.io/releases"
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.7"
|
python = "^3.8"
|
||||||
pydantic = "^1.9.1"
|
pydantic = "^1.9.1"
|
||||||
httpx = ">=0.23.0,<0.24.0"
|
httpx = ">=0.23.0,<0.25.0"
|
||||||
croniter = "^1.1.0"
|
croniter = ">=1.1,<3.0"
|
||||||
pytz = ">=2021.3,<2023.0"
|
pytz = ">=2021.3,<2024.0"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
pytest = "^7.2.1"
|
pytest = "^7.2.1"
|
||||||
coverage = {extras = ["toml"], version = "^7.1"}
|
coverage = {extras = ["toml"], version = "^7.1"}
|
||||||
safety = "^2.3.5"
|
safety = ">=2.3.5,<4.0.0"
|
||||||
mypy = "^1.0"
|
mypy = "^1.0"
|
||||||
xdoctest = {extras = ["colors"], version = "^1.1.1"}
|
xdoctest = {extras = ["colors"], version = "^1.1.1"}
|
||||||
sphinx = "^4.3.2"
|
sphinx = ">=4.3.2,<8.0.0"
|
||||||
sphinx-autobuild = ">=2021.3.14"
|
sphinx-autobuild = ">=2021.3.14"
|
||||||
pre-commit = "^2.21.0"
|
pre-commit = "^2.21.0"
|
||||||
reorder-python-imports = "^3.9.0"
|
reorder-python-imports = "^3.9.0"
|
||||||
pre-commit-hooks = "^4.4.0"
|
pre-commit-hooks = "^4.4.0"
|
||||||
pyupgrade = "^3.3.1"
|
pyupgrade = "^3.3.1"
|
||||||
furo = ">=2021.11.12"
|
furo = ">=2021.11.12"
|
||||||
pytest-cov = "^4.0.0"
|
pytest-cov = ">=4,<6"
|
||||||
types-croniter = "^1.3.2"
|
types-croniter = ">=1.3.2,<3.0.0"
|
||||||
types-pytz = "^2022.7.1"
|
types-pytz = ">=2022.7.1,<2024.0.0"
|
||||||
pytest-asyncio = "^0.20.3"
|
pytest-asyncio = ">=0.20.3,<0.24.0"
|
||||||
respx = "^0.20.1"
|
respx = ">=0.20.1,<0.22.0"
|
||||||
pytest-mock = "^3.10.0"
|
pytest-mock = "^3.10.0"
|
||||||
pytest-lazy-fixture = "^0.6.3"
|
pytest-lazy-fixture = "^0.6.3"
|
||||||
pytest-xdist = "^3.2.0"
|
pytest-xdist = "^3.2.0"
|
||||||
ruff = "^0.0.249"
|
ruff = ">=0.0.249,<0.4.4"
|
||||||
bandit = "^1.7.4"
|
bandit = "^1.7.4"
|
||||||
|
|
||||||
[tool.coverage.paths]
|
[tool.coverage.paths]
|
||||||
@@ -67,6 +67,9 @@ source = ["healthchecks_io"]
|
|||||||
show_missing = true
|
show_missing = true
|
||||||
fail_under = 100
|
fail_under = 100
|
||||||
|
|
||||||
|
[tool.bandit]
|
||||||
|
exclude_dirs = ["tests", "noxfile.py", ".github/scripts", "test_errbot", "dist"]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
strict = true
|
strict = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
@@ -76,7 +79,7 @@ show_error_codes = true
|
|||||||
show_error_context = true
|
show_error_context = true
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
@@ -84,4 +87,4 @@ addopts = "-n 4 --ignore examples --cov=healthchecks_io --cov-report xml:.covera
|
|||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
line-length = 120
|
line-length = 120
|
||||||
target-version = "py37"
|
target-version = "py38"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"""Py Healthchecks.Io."""
|
"""Py Healthchecks.Io."""
|
||||||
|
|
||||||
# set by poetry-dynamic-versioning
|
# set by poetry-dynamic-versioning
|
||||||
__version__ = "0.4.0" # noqa: E402
|
__version__ = "0.4.2" # noqa: E402
|
||||||
|
|
||||||
from .client import AsyncClient # noqa: F401, E402
|
from .client import AsyncClient # noqa: F401, E402
|
||||||
from .client import Client # noqa: F401, E402
|
from .client import Client # noqa: F401, E402
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""healthchecks_io clients."""
|
"""healthchecks_io clients."""
|
||||||
|
|
||||||
from .async_client import AsyncClient # noqa: F401
|
from .async_client import AsyncClient # noqa: F401
|
||||||
from .check_trap import CheckTrap # noqa: F401
|
from .check_trap import CheckTrap # noqa: F401
|
||||||
from .sync_client import Client # noqa: F401
|
from .sync_client import Client # noqa: F401
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ class AbstractClient(ABC):
|
|||||||
"""Finalizer method is called by weakref.finalize when the object is dereferenced to do cleanup of clients."""
|
"""Finalizer method is called by weakref.finalize when the object is dereferenced to do cleanup of clients."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _get_api_request_url(
|
def _get_api_request_url(self, path: str, params: Optional[Dict[str, Any]] = None) -> str:
|
||||||
self, path: str, params: Optional[Dict[str, Any]] = None
|
|
||||||
) -> str:
|
|
||||||
"""Get a full request url for the healthchecks api.
|
"""Get a full request url for the healthchecks api.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -165,9 +163,7 @@ class AbstractClient(ABC):
|
|||||||
raise CheckNotFoundError(f"CHeck not found at {response.request.url}")
|
raise CheckNotFoundError(f"CHeck not found at {response.request.url}")
|
||||||
|
|
||||||
if response.status_code == 400:
|
if response.status_code == 400:
|
||||||
raise BadAPIRequestError(
|
raise BadAPIRequestError(f"Bad request when requesting {response.request.url}. {response.text}")
|
||||||
f"Bad request when requesting {response.request.url}. {response.text}"
|
|
||||||
)
|
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@@ -208,21 +204,15 @@ class AbstractClient(ABC):
|
|||||||
raise HCAPIRateLimitError(f"Rate limited on {response.request.url}")
|
raise HCAPIRateLimitError(f"Rate limited on {response.request.url}")
|
||||||
|
|
||||||
if response.status_code == 400:
|
if response.status_code == 400:
|
||||||
raise BadAPIRequestError(
|
raise BadAPIRequestError(f"Bad request when requesting {response.request.url}. {response.text}")
|
||||||
f"Bad request when requesting {response.request.url}. {response.text}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if response.status_code == 409:
|
if response.status_code == 409:
|
||||||
raise NonUniqueSlugError(
|
raise NonUniqueSlugError(f"Bad request, slug conflict {response.request.url}. {response.text}")
|
||||||
f"Bad request, slug conflict {response.request.url}. {response.text}"
|
|
||||||
)
|
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _add_url_params(
|
def _add_url_params(url: str, params: Dict[str, Union[str, int, bool]], replace: bool = True) -> str:
|
||||||
url: str, params: Dict[str, Union[str, int, bool]], replace: bool = True
|
|
||||||
) -> str:
|
|
||||||
"""Add GET params to provided URL being aware of existing.
|
"""Add GET params to provided URL being aware of existing.
|
||||||
|
|
||||||
:param url: string of target URL
|
:param url: string of target URL
|
||||||
@@ -255,12 +245,7 @@ class AbstractClient(ABC):
|
|||||||
# get all the duplicated keys from params and urlencode them, we'll concat this to the params string later
|
# get all the duplicated keys from params and urlencode them, we'll concat this to the params string later
|
||||||
duplicated_params = [x for x in params if x in parsed_get_args]
|
duplicated_params = [x for x in params if x in parsed_get_args]
|
||||||
# get all the args that aren't duplicated and add them to parsed_get_args
|
# get all the args that aren't duplicated and add them to parsed_get_args
|
||||||
parsed_get_args.update(
|
parsed_get_args.update({key: parsed_params[key] for key in [x for x in params if x not in parsed_get_args]})
|
||||||
{
|
|
||||||
key: parsed_params[key]
|
|
||||||
for key in [x for x in params if x not in parsed_get_args]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# if we have any duplicated parameters, urlencode them, we append them later
|
# if we have any duplicated parameters, urlencode them, we append them later
|
||||||
extra_parameters = (
|
extra_parameters = (
|
||||||
f"&{urlencode({key: params[key] for key in duplicated_params}, doseq=True)}"
|
f"&{urlencode({key: params[key] for key in duplicated_params}, doseq=True)}"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""An async healthchecks.io client."""
|
"""An async healthchecks.io client."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""CheckTrap is a context manager to wrap around python code to communicate results to a Healthchecks check."""
|
"""CheckTrap is a context manager to wrap around python code to communicate results to a Healthchecks check."""
|
||||||
|
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@@ -68,9 +69,7 @@ class CheckTrap:
|
|||||||
CheckTrap: self
|
CheckTrap: self
|
||||||
"""
|
"""
|
||||||
if isinstance(self.client, AsyncClient):
|
if isinstance(self.client, AsyncClient):
|
||||||
raise WrongClientError(
|
raise WrongClientError("You passed an AsyncClient, use this as an async context manager")
|
||||||
"You passed an AsyncClient, use this as an async context manager"
|
|
||||||
)
|
|
||||||
result = self.client.start_ping(uuid=self.uuid, slug=self.slug)
|
result = self.client.start_ping(uuid=self.uuid, slug=self.slug)
|
||||||
if not result[0]:
|
if not result[0]:
|
||||||
raise PingFailedError(result[1])
|
raise PingFailedError(result[1])
|
||||||
@@ -96,9 +95,7 @@ class CheckTrap:
|
|||||||
Optional[bool]: self.suppress_exceptions, if true will not raise any exceptions
|
Optional[bool]: self.suppress_exceptions, if true will not raise any exceptions
|
||||||
"""
|
"""
|
||||||
if exc_type is None:
|
if exc_type is None:
|
||||||
self.client.success_ping(
|
self.client.success_ping(self.uuid, self.slug, data="\n".join(self.log_lines))
|
||||||
self.uuid, self.slug, data="\n".join(self.log_lines)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self.add_log(str(exc))
|
self.add_log(str(exc))
|
||||||
self.add_log(str(traceback))
|
self.add_log(str(traceback))
|
||||||
@@ -125,9 +122,7 @@ class CheckTrap:
|
|||||||
CheckTrap: self
|
CheckTrap: self
|
||||||
"""
|
"""
|
||||||
if isinstance(self.client, Client):
|
if isinstance(self.client, Client):
|
||||||
raise WrongClientError(
|
raise WrongClientError("You passed a sync Client, use this as a regular context manager")
|
||||||
"You passed a sync Client, use this as a regular context manager"
|
|
||||||
)
|
|
||||||
result = await self.client.start_ping(self.uuid, self.slug)
|
result = await self.client.start_ping(self.uuid, self.slug)
|
||||||
if not result[0]:
|
if not result[0]:
|
||||||
raise PingFailedError(result[1])
|
raise PingFailedError(result[1])
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""An async healthchecks.io client."""
|
"""An async healthchecks.io client."""
|
||||||
|
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Schemas for healthchecks_io."""
|
"""Schemas for healthchecks_io."""
|
||||||
|
|
||||||
from .badges import Badges
|
from .badges import Badges
|
||||||
from .checks import Check
|
from .checks import Check
|
||||||
from .checks import CheckCreate
|
from .checks import CheckCreate
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
https://healthchecks.io/docs/api/
|
https://healthchecks.io/docs/api/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
https://healthchecks.io/docs/api/
|
https://healthchecks.io/docs/api/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import PurePath
|
from pathlib import PurePath
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@@ -88,8 +89,7 @@ class CheckCreate(BaseModel):
|
|||||||
)
|
)
|
||||||
tz: Optional[str] = Field(
|
tz: Optional[str] = Field(
|
||||||
"UTC",
|
"UTC",
|
||||||
description="Server's timezone. This setting only has an effect "
|
description="Server's timezone. This setting only has an effect " "in combination with the schedule parameter.",
|
||||||
"in combination with the schedule parameter.",
|
|
||||||
)
|
)
|
||||||
manual_resume: Optional[bool] = Field(
|
manual_resume: Optional[bool] = Field(
|
||||||
False,
|
False,
|
||||||
@@ -184,8 +184,7 @@ class CheckUpdate(CheckCreate):
|
|||||||
)
|
)
|
||||||
tz: Optional[str] = Field(
|
tz: Optional[str] = Field(
|
||||||
None,
|
None,
|
||||||
description="Server's timezone. This setting only has an effect "
|
description="Server's timezone. This setting only has an effect " "in combination with the schedule parameter.",
|
||||||
"in combination with the schedule parameter.",
|
|
||||||
)
|
)
|
||||||
manual_resume: Optional[bool] = Field(
|
manual_resume: Optional[bool] = Field(
|
||||||
None,
|
None,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
https://healthchecks.io/docs/api/
|
https://healthchecks.io/docs/api/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ from healthchecks_io import NonUniqueSlugError
|
|||||||
|
|
||||||
|
|
||||||
def test_abstract_add_url_params(test_abstract_client):
|
def test_abstract_add_url_params(test_abstract_client):
|
||||||
|
url = test_abstract_client._add_url_params("http://test.com/?test=test", {"test": "test2"})
|
||||||
url = test_abstract_client._add_url_params(
|
|
||||||
"http://test.com/?test=test", {"test": "test2"}
|
|
||||||
)
|
|
||||||
assert url == "http://test.com/?test=test2"
|
assert url == "http://test.com/?test=test2"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ from healthchecks_io.client.exceptions import HCAPIError
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_acreate_check_200_context_manager(
|
async def test_acreate_check_200_context_manager(fake_check_api_result, respx_mock, test_async_client):
|
||||||
fake_check_api_result, respx_mock, test_async_client
|
|
||||||
):
|
|
||||||
checks_url = urljoin(test_async_client._api_url, "checks/")
|
checks_url = urljoin(test_async_client._api_url, "checks/")
|
||||||
respx_mock.post(checks_url).mock(
|
respx_mock.post(checks_url).mock(
|
||||||
return_value=Response(
|
return_value=Response(
|
||||||
@@ -43,9 +41,7 @@ async def test_acreate_check_200_context_manager(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
async with test_async_client as test_client:
|
async with test_async_client as test_client:
|
||||||
check = await test_client.create_check(
|
check = await test_client.create_check(CheckCreate(name="test", tags="test", desc="test"))
|
||||||
CheckCreate(name="test", tags="test", desc="test")
|
|
||||||
)
|
|
||||||
assert check.name == "Backups"
|
assert check.name == "Backups"
|
||||||
|
|
||||||
|
|
||||||
@@ -76,9 +72,7 @@ async def test_acreate_check_200(fake_check_api_result, respx_mock, test_async_c
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
check = await test_async_client.create_check(
|
check = await test_async_client.create_check(CheckCreate(name="test", tags="test", desc="test"))
|
||||||
CheckCreate(name="test", tags="test", desc="test")
|
|
||||||
)
|
|
||||||
assert check.name == "Backups"
|
assert check.name == "Backups"
|
||||||
|
|
||||||
|
|
||||||
@@ -109,9 +103,7 @@ async def test_aupdate_check_200(fake_check_api_result, respx_mock, test_async_c
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
check = await test_async_client.update_check(
|
check = await test_async_client.update_check("test", CheckUpdate(name="test", desc="test"))
|
||||||
"test", CheckUpdate(name="test", desc="test")
|
|
||||||
)
|
|
||||||
assert check.name == "Backups"
|
assert check.name == "Backups"
|
||||||
|
|
||||||
|
|
||||||
@@ -120,9 +112,7 @@ async def test_aupdate_check_200(fake_check_api_result, respx_mock, test_async_c
|
|||||||
async def test_aget_checks_200(fake_check_api_result, respx_mock, test_async_client):
|
async def test_aget_checks_200(fake_check_api_result, respx_mock, test_async_client):
|
||||||
assert test_async_client._client is not None
|
assert test_async_client._client is not None
|
||||||
checks_url = urljoin(test_async_client._api_url, "checks/")
|
checks_url = urljoin(test_async_client._api_url, "checks/")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json={"checks": [fake_check_api_result]}))
|
||||||
return_value=Response(status_code=200, json={"checks": [fake_check_api_result]})
|
|
||||||
)
|
|
||||||
checks = await test_async_client.get_checks()
|
checks = await test_async_client.get_checks()
|
||||||
assert len(checks) == 1
|
assert len(checks) == 1
|
||||||
assert checks[0].name == fake_check_api_result["name"]
|
assert checks[0].name == fake_check_api_result["name"]
|
||||||
@@ -132,13 +122,9 @@ async def test_aget_checks_200(fake_check_api_result, respx_mock, test_async_cli
|
|||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_aget_checks_pass_in_client(fake_check_api_result, respx_mock):
|
async def test_aget_checks_pass_in_client(fake_check_api_result, respx_mock):
|
||||||
httpx_client = HTTPXAsyncClient()
|
httpx_client = HTTPXAsyncClient()
|
||||||
test_async_client = AsyncClient(
|
test_async_client = AsyncClient(api_key="test", api_url="http://localhost/api/", client=httpx_client)
|
||||||
api_key="test", api_url="http://localhost/api/", client=httpx_client
|
|
||||||
)
|
|
||||||
checks_url = urljoin(test_async_client._api_url, "checks/")
|
checks_url = urljoin(test_async_client._api_url, "checks/")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json={"checks": [fake_check_api_result]}))
|
||||||
return_value=Response(status_code=200, json={"checks": [fake_check_api_result]})
|
|
||||||
)
|
|
||||||
checks = await test_async_client.get_checks()
|
checks = await test_async_client.get_checks()
|
||||||
assert len(checks) == 1
|
assert len(checks) == 1
|
||||||
assert checks[0].name == fake_check_api_result["name"]
|
assert checks[0].name == fake_check_api_result["name"]
|
||||||
@@ -146,9 +132,7 @@ async def test_aget_checks_pass_in_client(fake_check_api_result, respx_mock):
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_aget_checks_exceptions(
|
async def test_aget_checks_exceptions(fake_check_api_result, respx_mock, test_async_client):
|
||||||
fake_check_api_result, respx_mock, test_async_client
|
|
||||||
):
|
|
||||||
checks_url = urljoin(test_async_client._api_url, "checks/")
|
checks_url = urljoin(test_async_client._api_url, "checks/")
|
||||||
# test exceptions
|
# test exceptions
|
||||||
respx_mock.get(checks_url).mock(return_value=Response(status_code=401))
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=401))
|
||||||
@@ -186,9 +170,7 @@ def test_finalizer_closes(test_async_client):
|
|||||||
async def test_aget_check_200(fake_check_api_result, respx_mock, test_async_client):
|
async def test_aget_check_200(fake_check_api_result, respx_mock, test_async_client):
|
||||||
assert test_async_client._client is not None
|
assert test_async_client._client is not None
|
||||||
checks_url = urljoin(test_async_client._api_url, "checks/test")
|
checks_url = urljoin(test_async_client._api_url, "checks/test")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json=fake_check_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_check_api_result)
|
|
||||||
)
|
|
||||||
check = await test_async_client.get_check(check_id="test")
|
check = await test_async_client.get_check(check_id="test")
|
||||||
assert check.name == fake_check_api_result["name"]
|
assert check.name == fake_check_api_result["name"]
|
||||||
|
|
||||||
@@ -207,9 +189,7 @@ async def test_acheck_get_404(respx_mock, test_async_client):
|
|||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_pause_check_200(fake_check_api_result, respx_mock, test_async_client):
|
async def test_pause_check_200(fake_check_api_result, respx_mock, test_async_client):
|
||||||
checks_url = urljoin(test_async_client._api_url, "checks/test/pause")
|
checks_url = urljoin(test_async_client._api_url, "checks/test/pause")
|
||||||
respx_mock.post(checks_url).mock(
|
respx_mock.post(checks_url).mock(return_value=Response(status_code=200, json=fake_check_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_check_api_result)
|
|
||||||
)
|
|
||||||
check = await test_async_client.pause_check(check_id="test")
|
check = await test_async_client.pause_check(check_id="test")
|
||||||
assert check.name == fake_check_api_result["name"]
|
assert check.name == fake_check_api_result["name"]
|
||||||
|
|
||||||
@@ -229,9 +209,7 @@ async def test_acheck_pause_404(respx_mock, test_async_client):
|
|||||||
async def test_adelete_check_200(fake_check_api_result, respx_mock, test_async_client):
|
async def test_adelete_check_200(fake_check_api_result, respx_mock, test_async_client):
|
||||||
assert test_async_client._client is not None
|
assert test_async_client._client is not None
|
||||||
checks_url = urljoin(test_async_client._api_url, "checks/test")
|
checks_url = urljoin(test_async_client._api_url, "checks/test")
|
||||||
respx_mock.delete(checks_url).mock(
|
respx_mock.delete(checks_url).mock(return_value=Response(status_code=200, json=fake_check_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_check_api_result)
|
|
||||||
)
|
|
||||||
check = await test_async_client.delete_check(check_id="test")
|
check = await test_async_client.delete_check(check_id="test")
|
||||||
assert check.name == fake_check_api_result["name"]
|
assert check.name == fake_check_api_result["name"]
|
||||||
|
|
||||||
@@ -247,15 +225,9 @@ async def test_adelete_pause404(respx_mock, test_async_client):
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_aget_check_pings_200(
|
async def test_aget_check_pings_200(fake_check_pings_api_result, respx_mock, test_async_client):
|
||||||
fake_check_pings_api_result, respx_mock, test_async_client
|
|
||||||
):
|
|
||||||
checks_url = urljoin(test_async_client._api_url, "checks/test/pings/")
|
checks_url = urljoin(test_async_client._api_url, "checks/test/pings/")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json={"pings": fake_check_pings_api_result}))
|
||||||
return_value=Response(
|
|
||||||
status_code=200, json={"pings": fake_check_pings_api_result}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
pings = await test_async_client.get_check_pings("test")
|
pings = await test_async_client.get_check_pings("test")
|
||||||
assert len(pings) == len(fake_check_pings_api_result)
|
assert len(pings) == len(fake_check_pings_api_result)
|
||||||
assert pings[0].type == fake_check_pings_api_result[0]["type"]
|
assert pings[0].type == fake_check_pings_api_result[0]["type"]
|
||||||
@@ -263,13 +235,9 @@ async def test_aget_check_pings_200(
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_aget_check_flips_200(
|
async def test_aget_check_flips_200(fake_check_flips_api_result, respx_mock, test_async_client):
|
||||||
fake_check_flips_api_result, respx_mock, test_async_client
|
|
||||||
):
|
|
||||||
checks_url = urljoin(test_async_client._api_url, "checks/test/flips/")
|
checks_url = urljoin(test_async_client._api_url, "checks/test/flips/")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json=fake_check_flips_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_check_flips_api_result)
|
|
||||||
)
|
|
||||||
flips = await test_async_client.get_check_flips("test")
|
flips = await test_async_client.get_check_flips("test")
|
||||||
assert len(flips) == len(fake_check_flips_api_result)
|
assert len(flips) == len(fake_check_flips_api_result)
|
||||||
assert flips[0].up == fake_check_flips_api_result[0]["up"]
|
assert flips[0].up == fake_check_flips_api_result[0]["up"]
|
||||||
@@ -277,15 +245,9 @@ async def test_aget_check_flips_200(
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_get_check_flips_params_200(
|
async def test_get_check_flips_params_200(fake_check_flips_api_result, respx_mock, test_async_client):
|
||||||
fake_check_flips_api_result, respx_mock, test_async_client
|
checks_url = urljoin(test_async_client._api_url, "checks/test/flips/?seconds=1&start=1&end=1")
|
||||||
):
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json=fake_check_flips_api_result))
|
||||||
checks_url = urljoin(
|
|
||||||
test_async_client._api_url, "checks/test/flips/?seconds=1&start=1&end=1"
|
|
||||||
)
|
|
||||||
respx_mock.get(checks_url).mock(
|
|
||||||
return_value=Response(status_code=200, json=fake_check_flips_api_result)
|
|
||||||
)
|
|
||||||
flips = await test_async_client.get_check_flips("test", seconds=1, start=1, end=1)
|
flips = await test_async_client.get_check_flips("test", seconds=1, start=1, end=1)
|
||||||
assert len(flips) == len(fake_check_flips_api_result)
|
assert len(flips) == len(fake_check_flips_api_result)
|
||||||
assert flips[0].up == fake_check_flips_api_result[0]["up"]
|
assert flips[0].up == fake_check_flips_api_result[0]["up"]
|
||||||
@@ -293,9 +255,7 @@ async def test_get_check_flips_params_200(
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_aget_check_flips_400(
|
async def test_aget_check_flips_400(fake_check_flips_api_result, respx_mock, test_async_client):
|
||||||
fake_check_flips_api_result, respx_mock, test_async_client
|
|
||||||
):
|
|
||||||
flips_url = urljoin(test_async_client._api_url, "checks/test/flips/")
|
flips_url = urljoin(test_async_client._api_url, "checks/test/flips/")
|
||||||
respx_mock.get(flips_url).mock(return_value=Response(status_code=400))
|
respx_mock.get(flips_url).mock(return_value=Response(status_code=400))
|
||||||
with pytest.raises(BadAPIRequestError):
|
with pytest.raises(BadAPIRequestError):
|
||||||
@@ -304,13 +264,9 @@ async def test_aget_check_flips_400(
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_aget_integrations(
|
async def test_aget_integrations(fake_integrations_api_result, respx_mock, test_async_client):
|
||||||
fake_integrations_api_result, respx_mock, test_async_client
|
|
||||||
):
|
|
||||||
channels_url = urljoin(test_async_client._api_url, "channels/")
|
channels_url = urljoin(test_async_client._api_url, "channels/")
|
||||||
respx_mock.get(channels_url).mock(
|
respx_mock.get(channels_url).mock(return_value=Response(status_code=200, json=fake_integrations_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_integrations_api_result)
|
|
||||||
)
|
|
||||||
integrations = await test_async_client.get_integrations()
|
integrations = await test_async_client.get_integrations()
|
||||||
assert len(integrations) == len(fake_integrations_api_result["channels"])
|
assert len(integrations) == len(fake_integrations_api_result["channels"])
|
||||||
assert integrations[0].id == fake_integrations_api_result["channels"][0]["id"]
|
assert integrations[0].id == fake_integrations_api_result["channels"][0]["id"]
|
||||||
@@ -320,9 +276,7 @@ async def test_aget_integrations(
|
|||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
async def test_aget_badges(fake_badges_api_result, respx_mock, test_async_client):
|
async def test_aget_badges(fake_badges_api_result, respx_mock, test_async_client):
|
||||||
channels_url = urljoin(test_async_client._api_url, "badges/")
|
channels_url = urljoin(test_async_client._api_url, "badges/")
|
||||||
respx_mock.get(channels_url).mock(
|
respx_mock.get(channels_url).mock(return_value=Response(status_code=200, json=fake_badges_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_badges_api_result)
|
|
||||||
)
|
|
||||||
integrations = await test_async_client.get_badges()
|
integrations = await test_async_client.get_badges()
|
||||||
assert integrations.keys() == fake_badges_api_result["badges"].keys()
|
assert integrations.keys() == fake_badges_api_result["badges"].keys()
|
||||||
|
|
||||||
@@ -389,14 +343,10 @@ ping_test_parameters = [
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize("respx_mocker, tc, url, ping_method, method_kwargs", ping_test_parameters)
|
||||||
"respx_mocker, tc, url, ping_method, method_kwargs", ping_test_parameters
|
|
||||||
)
|
|
||||||
async def test_asuccess_ping(respx_mocker, tc, url, ping_method, method_kwargs):
|
async def test_asuccess_ping(respx_mocker, tc, url, ping_method, method_kwargs):
|
||||||
channels_url = urljoin(tc._ping_url, url)
|
channels_url = urljoin(tc._ping_url, url)
|
||||||
respx_mocker.post(channels_url).mock(
|
respx_mocker.post(channels_url).mock(return_value=Response(status_code=200, text="OK"))
|
||||||
return_value=Response(status_code=200, text="OK")
|
|
||||||
)
|
|
||||||
ping_method = getattr(tc, ping_method)
|
ping_method = getattr(tc, ping_method)
|
||||||
result = await ping_method(**method_kwargs)
|
result = await ping_method(**method_kwargs)
|
||||||
assert result[0] is True
|
assert result[0] is True
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ async def test_check_trap_async_exception(respx_mock, test_async_client):
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_check_trap_wrong_client_error(test_client, test_async_client):
|
async def test_check_trap_wrong_client_error(test_client, test_async_client):
|
||||||
|
|
||||||
with pytest.raises(WrongClientError):
|
with pytest.raises(WrongClientError):
|
||||||
async with CheckTrap(test_client, uuid="test"):
|
async with CheckTrap(test_client, uuid="test"):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ from healthchecks_io.client.exceptions import HCAPIError
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
def test_create_check_200_context_manager(
|
def test_create_check_200_context_manager(fake_check_api_result, respx_mock, test_client):
|
||||||
fake_check_api_result, respx_mock, test_client
|
|
||||||
):
|
|
||||||
checks_url = urljoin(test_client._api_url, "checks/")
|
checks_url = urljoin(test_client._api_url, "checks/")
|
||||||
respx_mock.post(checks_url).mock(
|
respx_mock.post(checks_url).mock(
|
||||||
return_value=Response(
|
return_value=Response(
|
||||||
@@ -110,9 +108,7 @@ def test_update_check_200(fake_check_api_result, respx_mock, test_client):
|
|||||||
def test_get_checks_200(fake_check_api_result, respx_mock, test_client):
|
def test_get_checks_200(fake_check_api_result, respx_mock, test_client):
|
||||||
assert test_client._client is not None
|
assert test_client._client is not None
|
||||||
checks_url = urljoin(test_client._api_url, "checks/")
|
checks_url = urljoin(test_client._api_url, "checks/")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json={"checks": [fake_check_api_result]}))
|
||||||
return_value=Response(status_code=200, json={"checks": [fake_check_api_result]})
|
|
||||||
)
|
|
||||||
checks = test_client.get_checks()
|
checks = test_client.get_checks()
|
||||||
assert len(checks) == 1
|
assert len(checks) == 1
|
||||||
assert checks[0].name == fake_check_api_result["name"]
|
assert checks[0].name == fake_check_api_result["name"]
|
||||||
@@ -121,13 +117,9 @@ def test_get_checks_200(fake_check_api_result, respx_mock, test_client):
|
|||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
def test_get_checks_pass_in_client(fake_check_api_result, respx_mock):
|
def test_get_checks_pass_in_client(fake_check_api_result, respx_mock):
|
||||||
httpx_client = HTTPXClient()
|
httpx_client = HTTPXClient()
|
||||||
test_client = Client(
|
test_client = Client(api_key="test", api_url="http://localhost/api/", client=httpx_client)
|
||||||
api_key="test", api_url="http://localhost/api/", client=httpx_client
|
|
||||||
)
|
|
||||||
checks_url = urljoin(test_client._api_url, "checks/")
|
checks_url = urljoin(test_client._api_url, "checks/")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json={"checks": [fake_check_api_result]}))
|
||||||
return_value=Response(status_code=200, json={"checks": [fake_check_api_result]})
|
|
||||||
)
|
|
||||||
checks = test_client.get_checks()
|
checks = test_client.get_checks()
|
||||||
assert len(checks) == 1
|
assert len(checks) == 1
|
||||||
assert checks[0].name == fake_check_api_result["name"]
|
assert checks[0].name == fake_check_api_result["name"]
|
||||||
@@ -169,9 +161,7 @@ def test_finalizer_closes(test_client):
|
|||||||
def test_get_check_200(fake_check_api_result, respx_mock, test_client):
|
def test_get_check_200(fake_check_api_result, respx_mock, test_client):
|
||||||
assert test_client._client is not None
|
assert test_client._client is not None
|
||||||
checks_url = urljoin(test_client._api_url, "checks/test")
|
checks_url = urljoin(test_client._api_url, "checks/test")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json=fake_check_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_check_api_result)
|
|
||||||
)
|
|
||||||
check = test_client.get_check(check_id="test")
|
check = test_client.get_check(check_id="test")
|
||||||
assert check.name == fake_check_api_result["name"]
|
assert check.name == fake_check_api_result["name"]
|
||||||
|
|
||||||
@@ -188,9 +178,7 @@ def test_check_get_404(respx_mock, test_client):
|
|||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
def test_pause_check_200(fake_check_api_result, respx_mock, test_client):
|
def test_pause_check_200(fake_check_api_result, respx_mock, test_client):
|
||||||
checks_url = urljoin(test_client._api_url, "checks/test/pause")
|
checks_url = urljoin(test_client._api_url, "checks/test/pause")
|
||||||
respx_mock.post(checks_url).mock(
|
respx_mock.post(checks_url).mock(return_value=Response(status_code=200, json=fake_check_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_check_api_result)
|
|
||||||
)
|
|
||||||
check = test_client.pause_check(check_id="test")
|
check = test_client.pause_check(check_id="test")
|
||||||
assert check.name == fake_check_api_result["name"]
|
assert check.name == fake_check_api_result["name"]
|
||||||
|
|
||||||
@@ -208,9 +196,7 @@ def test_check_pause_404(respx_mock, test_client):
|
|||||||
def test_delete_check_200(fake_check_api_result, respx_mock, test_client):
|
def test_delete_check_200(fake_check_api_result, respx_mock, test_client):
|
||||||
assert test_client._client is not None
|
assert test_client._client is not None
|
||||||
checks_url = urljoin(test_client._api_url, "checks/test")
|
checks_url = urljoin(test_client._api_url, "checks/test")
|
||||||
respx_mock.delete(checks_url).mock(
|
respx_mock.delete(checks_url).mock(return_value=Response(status_code=200, json=fake_check_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_check_api_result)
|
|
||||||
)
|
|
||||||
check = test_client.delete_check(check_id="test")
|
check = test_client.delete_check(check_id="test")
|
||||||
assert check.name == fake_check_api_result["name"]
|
assert check.name == fake_check_api_result["name"]
|
||||||
|
|
||||||
@@ -226,11 +212,7 @@ def test_delete_pause404(respx_mock, test_client):
|
|||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
def test_get_check_pings_200(fake_check_pings_api_result, respx_mock, test_client):
|
def test_get_check_pings_200(fake_check_pings_api_result, respx_mock, test_client):
|
||||||
checks_url = urljoin(test_client._api_url, "checks/test/pings/")
|
checks_url = urljoin(test_client._api_url, "checks/test/pings/")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json={"pings": fake_check_pings_api_result}))
|
||||||
return_value=Response(
|
|
||||||
status_code=200, json={"pings": fake_check_pings_api_result}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
pings = test_client.get_check_pings("test")
|
pings = test_client.get_check_pings("test")
|
||||||
assert len(pings) == len(fake_check_pings_api_result)
|
assert len(pings) == len(fake_check_pings_api_result)
|
||||||
assert pings[0].type == fake_check_pings_api_result[0]["type"]
|
assert pings[0].type == fake_check_pings_api_result[0]["type"]
|
||||||
@@ -239,24 +221,16 @@ def test_get_check_pings_200(fake_check_pings_api_result, respx_mock, test_clien
|
|||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
def test_get_check_flips_200(fake_check_flips_api_result, respx_mock, test_client):
|
def test_get_check_flips_200(fake_check_flips_api_result, respx_mock, test_client):
|
||||||
checks_url = urljoin(test_client._api_url, "checks/test/flips/")
|
checks_url = urljoin(test_client._api_url, "checks/test/flips/")
|
||||||
respx_mock.get(checks_url).mock(
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json=fake_check_flips_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_check_flips_api_result)
|
|
||||||
)
|
|
||||||
flips = test_client.get_check_flips("test")
|
flips = test_client.get_check_flips("test")
|
||||||
assert len(flips) == len(fake_check_flips_api_result)
|
assert len(flips) == len(fake_check_flips_api_result)
|
||||||
assert flips[0].up == fake_check_flips_api_result[0]["up"]
|
assert flips[0].up == fake_check_flips_api_result[0]["up"]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
def test_get_check_flips_params_200(
|
def test_get_check_flips_params_200(fake_check_flips_api_result, respx_mock, test_client):
|
||||||
fake_check_flips_api_result, respx_mock, test_client
|
checks_url = urljoin(test_client._api_url, "checks/test/flips/?seconds=1&start=1&end=1")
|
||||||
):
|
respx_mock.get(checks_url).mock(return_value=Response(status_code=200, json=fake_check_flips_api_result))
|
||||||
checks_url = urljoin(
|
|
||||||
test_client._api_url, "checks/test/flips/?seconds=1&start=1&end=1"
|
|
||||||
)
|
|
||||||
respx_mock.get(checks_url).mock(
|
|
||||||
return_value=Response(status_code=200, json=fake_check_flips_api_result)
|
|
||||||
)
|
|
||||||
flips = test_client.get_check_flips("test", seconds=1, start=1, end=1)
|
flips = test_client.get_check_flips("test", seconds=1, start=1, end=1)
|
||||||
assert len(flips) == len(fake_check_flips_api_result)
|
assert len(flips) == len(fake_check_flips_api_result)
|
||||||
assert flips[0].up == fake_check_flips_api_result[0]["up"]
|
assert flips[0].up == fake_check_flips_api_result[0]["up"]
|
||||||
@@ -273,9 +247,7 @@ def test_get_check_flips_400(fake_check_flips_api_result, respx_mock, test_clien
|
|||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
def test_get_integrations(fake_integrations_api_result, respx_mock, test_client):
|
def test_get_integrations(fake_integrations_api_result, respx_mock, test_client):
|
||||||
channels_url = urljoin(test_client._api_url, "channels/")
|
channels_url = urljoin(test_client._api_url, "channels/")
|
||||||
respx_mock.get(channels_url).mock(
|
respx_mock.get(channels_url).mock(return_value=Response(status_code=200, json=fake_integrations_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_integrations_api_result)
|
|
||||||
)
|
|
||||||
integrations = test_client.get_integrations()
|
integrations = test_client.get_integrations()
|
||||||
assert len(integrations) == len(fake_integrations_api_result["channels"])
|
assert len(integrations) == len(fake_integrations_api_result["channels"])
|
||||||
assert integrations[0].id == fake_integrations_api_result["channels"][0]["id"]
|
assert integrations[0].id == fake_integrations_api_result["channels"][0]["id"]
|
||||||
@@ -284,9 +256,7 @@ def test_get_integrations(fake_integrations_api_result, respx_mock, test_client)
|
|||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
def test_get_badges(fake_badges_api_result, respx_mock, test_client):
|
def test_get_badges(fake_badges_api_result, respx_mock, test_client):
|
||||||
channels_url = urljoin(test_client._api_url, "badges/")
|
channels_url = urljoin(test_client._api_url, "badges/")
|
||||||
respx_mock.get(channels_url).mock(
|
respx_mock.get(channels_url).mock(return_value=Response(status_code=200, json=fake_badges_api_result))
|
||||||
return_value=Response(status_code=200, json=fake_badges_api_result)
|
|
||||||
)
|
|
||||||
integrations = test_client.get_badges()
|
integrations = test_client.get_badges()
|
||||||
assert integrations.keys() == fake_badges_api_result["badges"].keys()
|
assert integrations.keys() == fake_badges_api_result["badges"].keys()
|
||||||
|
|
||||||
@@ -352,14 +322,10 @@ ping_test_parameters = [
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.respx
|
@pytest.mark.respx
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize("respx_mocker, tc, url, ping_method, method_kwargs", ping_test_parameters)
|
||||||
"respx_mocker, tc, url, ping_method, method_kwargs", ping_test_parameters
|
|
||||||
)
|
|
||||||
def test_success_ping(respx_mocker, tc, url, ping_method, method_kwargs):
|
def test_success_ping(respx_mocker, tc, url, ping_method, method_kwargs):
|
||||||
channels_url = urljoin(tc._ping_url, url)
|
channels_url = urljoin(tc._ping_url, url)
|
||||||
respx_mocker.post(channels_url).mock(
|
respx_mocker.post(channels_url).mock(return_value=Response(status_code=200, text="OK"))
|
||||||
return_value=Response(status_code=200, text="OK")
|
|
||||||
)
|
|
||||||
ping_method = getattr(tc, ping_method)
|
ping_method = getattr(tc, ping_method)
|
||||||
result, text = ping_method(**method_kwargs)
|
result, text = ping_method(**method_kwargs)
|
||||||
assert result is True
|
assert result is True
|
||||||
|
|||||||
@@ -37,27 +37,19 @@ def test_check_create_validators():
|
|||||||
|
|
||||||
# test validate_schedule
|
# test validate_schedule
|
||||||
with pytest.raises(ValidationError):
|
with pytest.raises(ValidationError):
|
||||||
check_create = checks.CheckCreate(
|
check_create = checks.CheckCreate(name="Test", tags="", desc="Test", schedule="no good")
|
||||||
name="Test", tags="", desc="Test", schedule="no good"
|
|
||||||
)
|
|
||||||
|
|
||||||
# test validate_tz
|
# test validate_tz
|
||||||
with pytest.raises(ValidationError):
|
with pytest.raises(ValidationError):
|
||||||
check_create = checks.CheckCreate(
|
check_create = checks.CheckCreate(name="Test", tags="", desc="Test", tz="no good")
|
||||||
name="Test", tags="", desc="Test", tz="no good"
|
|
||||||
)
|
|
||||||
|
|
||||||
# test validate_methods
|
# test validate_methods
|
||||||
with pytest.raises(ValidationError):
|
with pytest.raises(ValidationError):
|
||||||
check_create = checks.CheckCreate(
|
check_create = checks.CheckCreate(name="Test", tags="", desc="Test", methods="no good")
|
||||||
name="Test", tags="", desc="Test", methods="no good"
|
|
||||||
)
|
|
||||||
|
|
||||||
# test validate_unique
|
# test validate_unique
|
||||||
with pytest.raises(ValidationError):
|
with pytest.raises(ValidationError):
|
||||||
check_create = checks.CheckCreate(
|
check_create = checks.CheckCreate(name="Test", tags="", desc="Test", unique=["no good"])
|
||||||
name="Test", tags="", desc="Test", unique=["no good"]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_check_pings_from_api():
|
def test_check_pings_from_api():
|
||||||
|
|||||||
Reference in New Issue
Block a user