Skip to content

Commit

Permalink
Add test for warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingface0 committed Aug 8, 2024
1 parent 178e3cc commit 514cd5e
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import json
import warnings

from runregistry.runregistry import (
get_run,
Expand All @@ -12,7 +13,7 @@
get_lumisection_ranges,
# get_oms_lumisection_ranges,
get_joint_lumisection_ranges,
# generate_json,
generate_json,
create_json,
setup,
)
Expand Down Expand Up @@ -201,6 +202,35 @@ def test_get_datasets_with_filter():
assert len(datasets) > 0


def test_generate_json():
# https://docs.python.org/3/library/warnings.html#testing-warnings
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
generate_json(
"""
{
"and": [
{
"or": [
{
"==": [
{
"var": "dataset.name"
},
"/PromptReco/Collisions2018A/DQM"
]
}
]
}
]
}
"""
)
assert len(w) == 1
assert issubclass(w[-1].category, PendingDeprecationWarning)
assert "deprecated" in str(w[-1].message)


# UNSAFE:
# def test_generate_json():
# json_logic = """
Expand Down

0 comments on commit 514cd5e

Please sign in to comment.