Skip to content

Commit

Permalink
fix: add freezegun in ci and update deps (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare authored Jan 9, 2024
1 parent 317033b commit 0d65a95
Show file tree
Hide file tree
Showing 9 changed files with 889 additions and 141 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ venv/
__pycache__/
.coverage
.github/
site/
trivy.*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
venv/
__pycache__/
.coverage
site/
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- --py311-plus
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: "v0.0.291"
rev: "v0.1.11"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
10 changes: 10 additions & 0 deletions docs/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* set primary color */
:root {
--md-primary-fg-color: #00C9BF;
--md-accent-fg-color: #00C9BF;
}

/* make code selectable on main */
.highlight .o {
user-select: none;
}
33 changes: 33 additions & 0 deletions docs/gen_ref_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Generate the code reference pages and navigation.
From https://mkdocstrings.github.io/recipes/
"""

from pathlib import Path

import mkdocs_gen_files

nav = mkdocs_gen_files.Nav()

path = Path("acrmonitor.py")
module_path = path.relative_to(".").with_suffix("")
doc_path = path.relative_to(".").with_suffix(".md")
full_doc_path = Path("reference", doc_path)

parts = tuple(module_path.parts)

nav[parts] = doc_path.as_posix()

full_doc_path.parent.mkdir(parents=True, exist_ok=True)
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
ident = ".".join(parts)
fd.write(f"::: {ident}")

mkdocs_gen_files.set_edit_path(full_doc_path, path)

with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
nav_file.writelines(nav.build_literate_nav())

readme = Path("README.md").open("r")
with mkdocs_gen_files.open("index.md", "w") as index_file:
index_file.writelines(readme.read())
54 changes: 54 additions & 0 deletions mkdocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
site_name: RaBe ACR Monitoring
repo_url: https://github.com/radiorabe/acr-monitoring
repo_name: radiorabe/acr-monitoring

theme:
name: "material"
palette:
# Palette toggle for dark mode
- scheme: slate
toggle:
icon: material/brightness-4
name: Switch to light mode
# Palette toggle for light mode
- scheme: default
toggle:
icon: material/brightness-7
name: Switch to dark mode
icon:
repo: fontawesome/brands/git-alt
features:
- content.code.copy
- toc.integrate

markdown_extensions:
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences

extra_css:
- css/style.css

plugins:
- search
- autorefs
- gen-files:
scripts:
- docs/gen_ref_pages.py
- literate-nav:
nav_file: SUMMARY.md
- section-index
- mkdocstrings:
handlers:
python:
paths: [.]

nav:
- README: index.md
- Python Reference: reference/

watch:
- README.md
- acrmonitor.py
904 changes: 772 additions & 132 deletions poetry.lock

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@ acrmonitor = 'acrmonitor:main'

[tool.poetry.dependencies]
python = "^3.11"
cloudevents = "^1.10.0"
cloudevents = "^1.10.1"
ConfigArgParse = "^1.7"
kafka-python = "^2.0.2"
py-zabbix = "^1.1.7"
minio = "^7.1.17"
minio = "^7.2.3"

[tool.poetry.group.dev.dependencies]
black = "^23.9.1"
pytest = "^7.4.2"
pytest-ruff = "^0.1.1"
black = "^23.12.1"
pytest = "^7.4.4"
pytest-ruff = "^0.2.1"
pytest-cov = "^4.1.0"
pytest-random-order = "^1.1.0"
ruff = "^0.0.291"
isort = "^5.12.0"
ruff = "^0.1.11"
isort = "^5.13.2"
pytest-isort = "^3.1.0"
mkdocs = "^1.5.3"
freezegun = "^1.4.0"
mkdocs-material = "^9.5.3"
mkdocs-gen-files = "^0.5.0"
mkdocs-literate-nav = "^0.6.1"
mkdocs-section-index = "^0.3.8"
mkdocs-autorefs = "^0.5.0"
mkdocstrings = {extras = ["python"], version = "^0.24.0"}

[tool.isort]
profile = "black"
Expand Down
4 changes: 3 additions & 1 deletion test_acrmonitor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from io import BytesIO
from unittest.mock import patch

from freezegun import freeze_time
from kafka.consumer.fetcher import ConsumerRecord
from urllib3.response import HTTPResponse

Expand Down Expand Up @@ -44,6 +45,7 @@ def test_read_from_event(sender, mc, send_from_data):

@patch("acrmonitor.ZabbixSender")
@patch("acrmonitor.ZabbixMetric")
@freeze_time("1970-01-01 16:20:00")
def test_send_from_data(metric, sender):
data = {
"metadata": {
Expand All @@ -61,6 +63,6 @@ def test_send_from_data(metric, sender):
host="zabbix.example.com",
key="key.example.com",
value="1234567890",
clock=11520.0,
clock=47520.0,
)
sender.send.assert_called_with([metric()])

0 comments on commit 0d65a95

Please sign in to comment.