mirror of
https://github.com/SigNoz/signoz.git
synced 2026-02-03 08:33:26 +00:00
Some checks failed
build-staging / prepare (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
* chore: fixture for notification channel * chore: return notification channel info in Create notification channel API * fix: change scope of create channel fixture to function level * test: added fixture for creating alert rule * chore: added debug message on assertion failure * refactor: improve error handling in webhook notification channel deletion * fix: enhance error handling in alert rule creation and deletion * chore: ran py linter and fmt * chore: ran py linter and fmt * fix: add timeout to alert rule creation and deletion requests * fix: silenced pylint on too broad exception * fix: suppress pylint warnings for broad exception handling in alert rule deletion * test: added fixture for inserting alert data * refactor: added fixture for getting test data file path * feat: add alerts to integration CI workflow * chore: linter fixes * chore: changed scope for get_testdata_file_path * chore: py-formatter * chore: py-formatter * chore: updated get_testdata_file_path fixture to a util function * chore: removed wrong ref --------- Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
34 lines
968 B
Python
34 lines
968 B
Python
import datetime
|
|
import os
|
|
from typing import Any
|
|
|
|
import isodate
|
|
|
|
|
|
# parses the given timestamp string from ISO format to datetime.datetime
|
|
def parse_timestamp(ts_str: str) -> datetime.datetime:
|
|
"""
|
|
Parse a timestamp string from ISO format.
|
|
"""
|
|
if ts_str.endswith("Z"):
|
|
ts_str = ts_str[:-1] + "+00:00"
|
|
return datetime.datetime.fromisoformat(ts_str)
|
|
|
|
|
|
# parses the given duration to datetime.timedelta
|
|
def parse_duration(duration: Any) -> datetime.timedelta:
|
|
"""
|
|
Parse a duration string from ISO format.
|
|
"""
|
|
# if it's string then parse it as iso format
|
|
if isinstance(duration, str):
|
|
return isodate.parse_duration(duration)
|
|
if isinstance(duration, datetime.timedelta):
|
|
return duration
|
|
return datetime.timedelta(seconds=duration)
|
|
|
|
|
|
def get_testdata_file_path(file: str) -> str:
|
|
testdata_dir = os.path.join(os.path.dirname(__file__), "..", "testdata")
|
|
return os.path.join(testdata_dir, file)
|