django-alive-checks 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ name: Django Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ python-version: ['3.9', '3.10', '3.11', '3.12']
16
+ django-version: ['4.2.*', '5.0.*', '5.1.*']
17
+
18
+ exclude:
19
+ # Django 5.x does not support Python 3.9
20
+ - python-version: '3.9'
21
+ django-version: '5.1.*'
22
+
23
+ - python-version: '3.9'
24
+ django-version: '5.0.*'
25
+
26
+ # Python 3.12 is not supported with Django 4.2
27
+ - python-version: '3.12'
28
+ django-version: '4.2.*'
29
+ fail-fast: false
30
+
31
+ steps:
32
+ - uses: actions/checkout@v3
33
+
34
+ - name: Set up Python ${{ matrix.python-version }}
35
+ uses: actions/setup-python@v4
36
+ with:
37
+ python-version: ${{ matrix.python-version }}
38
+
39
+ - name: Install dependencies
40
+ run: |
41
+ python -m pip install --upgrade pip
42
+ pip install tox black isort
43
+
44
+ - name: Run tests
45
+ run: |
46
+ pip install "Django==${{ matrix.django-version }}"
47
+ pip install -e .[elasticsearch]
48
+ python -m unittest discover
49
+
50
+ - name: Check code style with black
51
+ run: |
52
+ black --check .
53
+
54
+ - name: Check import order with isort
55
+ run: |
56
+ isort --check-only .
@@ -0,0 +1,51 @@
1
+ *.py[cod]
2
+
3
+ # C extensions
4
+ *.so
5
+
6
+ # Packages
7
+ *.egg
8
+ *.egg-info
9
+ dist
10
+ build
11
+ eggs
12
+ parts
13
+ bin
14
+ var
15
+ sdist
16
+ develop-eggs
17
+ .installed.cfg
18
+ lib
19
+ lib64
20
+
21
+ # Installer logs
22
+ pip-log.txt
23
+
24
+ # Unit test / coverage reports
25
+ .coverage
26
+ .tox
27
+ nosetests.xml
28
+
29
+ # Translations
30
+ *.mo
31
+
32
+ # Mr Developer
33
+ .mr.developer.cfg
34
+ .project
35
+ .pydevproject
36
+ demoproject/static
37
+
38
+ *.db
39
+ *nbproject*
40
+ *devserver*
41
+ *.idea*
42
+ docs/build/*
43
+ build/
44
+ dist/
45
+ *.egg-info/*
46
+ *sublime*
47
+ *~
48
+ *.swp
49
+ *.swo
50
+ *.swn
51
+ *.orig
@@ -0,0 +1,23 @@
1
+ All original code is provided under the MIT License:
2
+
3
+ The MIT License (MIT)
4
+
5
+ Copyright (c) 2018 Lincoln Loop, LLC
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.1
2
+ Name: django-alive-checks
3
+ Version: 0.1
4
+ Summary: Additional health checks for django-alive
5
+ Home-page: https://github.com/PetrDlouhy/django-alive-checks
6
+ Author: Your Name
7
+ Author-email: your.email@example.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Framework :: Django
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Description-Content-Type: text/x-rst
15
+ License-File: LICENSE
16
+ Requires-Dist: Django>=3.2
17
+ Requires-Dist: django-alive
18
+ Provides-Extra: elasticsearch
19
+ Requires-Dist: elasticsearch>=7.0.0; extra == "elasticsearch"
20
+
21
+ django-alive-checks
22
+ ===================
23
+
24
+ `django-alive-checks` is a Django application that provides additional health checks for your Django projects. These checks are designed to work with the `django-alive <https://github.com/pinax/django-alive>`_ package but include dependencies that cannot be part of `django-alive` itself.
25
+
26
+ Installation
27
+ ------------
28
+
29
+ You can install the base package with:
30
+
31
+ .. code-block:: bash
32
+
33
+ pip install django-alive-checks
34
+
35
+ If you want to include support for Elasticsearch, install with:
36
+
37
+ .. code-block:: bash
38
+
39
+ pip install django-alive-checks[elasticsearch]
40
+
41
+
42
+ Integration with django-alive
43
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44
+
45
+ To integrate the ``check_elasticsearch`` function with your ``django-alive`` checks, you can add it to your health checks configuration:
46
+
47
+ .. code-block:: python
48
+
49
+ # settings.py
50
+
51
+ ALIVE_CHECKS = [
52
+ ...
53
+ ("alive_checks.checks.check_elasticsearch", {"settings": ES_SETTINGS}),
54
+ ]
55
+
56
+ Where the ``ES_SETTINGS`` contains settings that you pass to ``elsaticsearch.Elasticsearch``.
57
+
58
+
59
+ Testing
60
+ -------
61
+
62
+ To run the tests for this project:
63
+
64
+ .. code-block:: bash
65
+
66
+ python -m unittest discover
67
+
68
+ The tests cover the following scenarios:
69
+
70
+ - Successful connection to Elasticsearch.
71
+ - Failed connection to Elasticsearch.
72
+ - Exceptions during connection attempts.
73
+ - Handling the absence of the ``elasticsearch`` package.
74
+
75
+ Contributing
76
+ ------------
77
+
78
+ Contributions are welcome! If you encounter any issues, have ideas for improvements, or want to add more checks, feel free to open an issue or submit a pull request.
79
+
80
+ License
81
+ -------
82
+
83
+ This project is licensed under the MIT License. See the `LICENSE` file for more details.
84
+
85
+ Acknowledgments
86
+ ---------------
87
+
88
+ Thanks to the Django and Elasticsearch communities for their continued support and development of the libraries that make this project possible.
89
+
@@ -0,0 +1,69 @@
1
+ django-alive-checks
2
+ ===================
3
+
4
+ `django-alive-checks` is a Django application that provides additional health checks for your Django projects. These checks are designed to work with the `django-alive <https://github.com/pinax/django-alive>`_ package but include dependencies that cannot be part of `django-alive` itself.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ You can install the base package with:
10
+
11
+ .. code-block:: bash
12
+
13
+ pip install django-alive-checks
14
+
15
+ If you want to include support for Elasticsearch, install with:
16
+
17
+ .. code-block:: bash
18
+
19
+ pip install django-alive-checks[elasticsearch]
20
+
21
+
22
+ Integration with django-alive
23
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24
+
25
+ To integrate the ``check_elasticsearch`` function with your ``django-alive`` checks, you can add it to your health checks configuration:
26
+
27
+ .. code-block:: python
28
+
29
+ # settings.py
30
+
31
+ ALIVE_CHECKS = [
32
+ ...
33
+ ("alive_checks.checks.check_elasticsearch", {"settings": ES_SETTINGS}),
34
+ ]
35
+
36
+ Where the ``ES_SETTINGS`` contains settings that you pass to ``elsaticsearch.Elasticsearch``.
37
+
38
+
39
+ Testing
40
+ -------
41
+
42
+ To run the tests for this project:
43
+
44
+ .. code-block:: bash
45
+
46
+ python -m unittest discover
47
+
48
+ The tests cover the following scenarios:
49
+
50
+ - Successful connection to Elasticsearch.
51
+ - Failed connection to Elasticsearch.
52
+ - Exceptions during connection attempts.
53
+ - Handling the absence of the ``elasticsearch`` package.
54
+
55
+ Contributing
56
+ ------------
57
+
58
+ Contributions are welcome! If you encounter any issues, have ideas for improvements, or want to add more checks, feel free to open an issue or submit a pull request.
59
+
60
+ License
61
+ -------
62
+
63
+ This project is licensed under the MIT License. See the `LICENSE` file for more details.
64
+
65
+ Acknowledgments
66
+ ---------------
67
+
68
+ Thanks to the Django and Elasticsearch communities for their continued support and development of the libraries that make this project possible.
69
+
File without changes
@@ -0,0 +1,6 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class AliveChecksConfig(AppConfig):
5
+ default_auto_field = "django.db.models.BigAutoField"
6
+ name = "alive_checks"
@@ -0,0 +1 @@
1
+ from .elasticsearch import *
@@ -0,0 +1,38 @@
1
+ import logging
2
+
3
+ from django.core.exceptions import ImproperlyConfigured
4
+
5
+ try:
6
+ from elasticsearch import Elasticsearch
7
+ except ImportError:
8
+ Elasticsearch = None
9
+
10
+
11
+ class HealthcheckFailure(Exception):
12
+ pass
13
+
14
+
15
+ log = logging.getLogger(__name__)
16
+
17
+
18
+ def check_elasticsearch(settings=None):
19
+ # type: (dict) -> None
20
+ """
21
+ Ping the Elasticsearch server to verify it's reachable
22
+ :param dict settings: Elasticsearch settings
23
+ :return None:
24
+ """
25
+ if Elasticsearch is None:
26
+ raise ImproperlyConfigured("elasticsearch package is not installed")
27
+
28
+ if settings is None:
29
+ settings = {}
30
+
31
+ try:
32
+ ping = Elasticsearch(settings).ping()
33
+ except Exception:
34
+ log.exception("Elasticsearch connection failed")
35
+ raise HealthcheckFailure("Elasticsearch exception")
36
+ if not ping:
37
+ log.error("Elasticsearch ping failed")
38
+ raise HealthcheckFailure("Elasticsearch error")
File without changes
@@ -0,0 +1,28 @@
1
+ from unittest import TestCase, mock
2
+
3
+ from django.core.exceptions import ImproperlyConfigured
4
+
5
+ from alive_checks.checks import HealthcheckFailure, check_elasticsearch
6
+
7
+
8
+ class ElasticsearchCheckTests(TestCase):
9
+
10
+ @mock.patch("alive_checks.checks.elasticsearch.Elasticsearch")
11
+ def test_elasticsearch_ping_success(self, mock_elasticsearch):
12
+ mock_elasticsearch.return_value.ping.return_value = True
13
+ try:
14
+ check_elasticsearch()
15
+ except HealthcheckFailure:
16
+ self.fail("HealthcheckFailure raised unexpectedly")
17
+
18
+ @mock.patch("alive_checks.checks.elasticsearch.Elasticsearch")
19
+ def test_elasticsearch_ping_failure(self, mock_elasticsearch):
20
+ mock_elasticsearch.return_value.ping.return_value = False
21
+ with self.assertRaises(HealthcheckFailure):
22
+ check_elasticsearch()
23
+
24
+ @mock.patch("alive_checks.checks.elasticsearch.Elasticsearch")
25
+ def test_elasticsearch_exception(self, mock_elasticsearch):
26
+ mock_elasticsearch.side_effect = Exception("Connection failed")
27
+ with self.assertRaises(HealthcheckFailure):
28
+ check_elasticsearch()
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.1
2
+ Name: django-alive-checks
3
+ Version: 0.1
4
+ Summary: Additional health checks for django-alive
5
+ Home-page: https://github.com/PetrDlouhy/django-alive-checks
6
+ Author: Your Name
7
+ Author-email: your.email@example.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Framework :: Django
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Description-Content-Type: text/x-rst
15
+ License-File: LICENSE
16
+ Requires-Dist: Django>=3.2
17
+ Requires-Dist: django-alive
18
+ Provides-Extra: elasticsearch
19
+ Requires-Dist: elasticsearch>=7.0.0; extra == "elasticsearch"
20
+
21
+ django-alive-checks
22
+ ===================
23
+
24
+ `django-alive-checks` is a Django application that provides additional health checks for your Django projects. These checks are designed to work with the `django-alive <https://github.com/pinax/django-alive>`_ package but include dependencies that cannot be part of `django-alive` itself.
25
+
26
+ Installation
27
+ ------------
28
+
29
+ You can install the base package with:
30
+
31
+ .. code-block:: bash
32
+
33
+ pip install django-alive-checks
34
+
35
+ If you want to include support for Elasticsearch, install with:
36
+
37
+ .. code-block:: bash
38
+
39
+ pip install django-alive-checks[elasticsearch]
40
+
41
+
42
+ Integration with django-alive
43
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44
+
45
+ To integrate the ``check_elasticsearch`` function with your ``django-alive`` checks, you can add it to your health checks configuration:
46
+
47
+ .. code-block:: python
48
+
49
+ # settings.py
50
+
51
+ ALIVE_CHECKS = [
52
+ ...
53
+ ("alive_checks.checks.check_elasticsearch", {"settings": ES_SETTINGS}),
54
+ ]
55
+
56
+ Where the ``ES_SETTINGS`` contains settings that you pass to ``elsaticsearch.Elasticsearch``.
57
+
58
+
59
+ Testing
60
+ -------
61
+
62
+ To run the tests for this project:
63
+
64
+ .. code-block:: bash
65
+
66
+ python -m unittest discover
67
+
68
+ The tests cover the following scenarios:
69
+
70
+ - Successful connection to Elasticsearch.
71
+ - Failed connection to Elasticsearch.
72
+ - Exceptions during connection attempts.
73
+ - Handling the absence of the ``elasticsearch`` package.
74
+
75
+ Contributing
76
+ ------------
77
+
78
+ Contributions are welcome! If you encounter any issues, have ideas for improvements, or want to add more checks, feel free to open an issue or submit a pull request.
79
+
80
+ License
81
+ -------
82
+
83
+ This project is licensed under the MIT License. See the `LICENSE` file for more details.
84
+
85
+ Acknowledgments
86
+ ---------------
87
+
88
+ Thanks to the Django and Elasticsearch communities for their continued support and development of the libraries that make this project possible.
89
+
@@ -0,0 +1,16 @@
1
+ .gitignore
2
+ LICENSE
3
+ README.rst
4
+ setup.py
5
+ .github/workflows/python-tests.yml
6
+ alive_checks/__init__.py
7
+ alive_checks/apps.py
8
+ alive_checks/checks/__init__.py
9
+ alive_checks/checks/elasticsearch.py
10
+ alive_checks/tests/__init__.py
11
+ alive_checks/tests/test_elasticsearch_check.py
12
+ django_alive_checks.egg-info/PKG-INFO
13
+ django_alive_checks.egg-info/SOURCES.txt
14
+ django_alive_checks.egg-info/dependency_links.txt
15
+ django_alive_checks.egg-info/requires.txt
16
+ django_alive_checks.egg-info/top_level.txt
@@ -0,0 +1,5 @@
1
+ Django>=3.2
2
+ django-alive
3
+
4
+ [elasticsearch]
5
+ elasticsearch>=7.0.0
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,29 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ setup(
4
+ name="django-alive-checks",
5
+ version="0.1",
6
+ packages=find_packages(),
7
+ include_package_data=True,
8
+ install_requires=[
9
+ "Django>=3.2",
10
+ "django-alive",
11
+ ],
12
+ extras_require={
13
+ "elasticsearch": ["elasticsearch>=7.0.0"],
14
+ },
15
+ description="Additional health checks for django-alive",
16
+ long_description=open("README.rst").read(),
17
+ long_description_content_type="text/x-rst",
18
+ url="https://github.com/PetrDlouhy/django-alive-checks",
19
+ author="Your Name",
20
+ author_email="your.email@example.com",
21
+ classifiers=[
22
+ "Development Status :: 3 - Alpha",
23
+ "Framework :: Django",
24
+ "Intended Audience :: Developers",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.8",
28
+ ],
29
+ )