lvi-api-client 0.2.9__tar.gz → 0.2.11__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.
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/PKG-INFO +1 -1
- lvi_api_client-0.2.11/VERSION +1 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/src/logicvein/lvi_api_client.py +10 -2
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/src/lvi_api_client.egg-info/PKG-INFO +1 -1
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/src/lvi_api_client.egg-info/SOURCES.txt +1 -0
- lvi_api_client-0.2.11/tests/test_promote_pypi.py +70 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/tests/test_server_request_shapes.py +16 -0
- lvi_api_client-0.2.9/VERSION +0 -1
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/LICENSE +0 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/README.md +0 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/pyproject.toml +0 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/setup.cfg +0 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/src/logicvein/__init__.py +0 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/src/lvi_api_client.egg-info/dependency_links.txt +0 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/src/lvi_api_client.egg-info/requires.txt +0 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/src/lvi_api_client.egg-info/top_level.txt +0 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/tests/test_check_version_bump.py +0 -0
- {lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/tests/test_lvi_api_client.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.2.11
|
|
@@ -4278,6 +4278,7 @@ class LogicVeinAPIClient:
|
|
|
4278
4278
|
sort_column: str = "policyName",
|
|
4279
4279
|
descending: bool = False,
|
|
4280
4280
|
page_size: int = 500,
|
|
4281
|
+
strict: bool = False,
|
|
4281
4282
|
) -> List[Dict[str, Any]]:
|
|
4282
4283
|
"""Search and list alert policies.
|
|
4283
4284
|
|
|
@@ -4297,11 +4298,17 @@ class LogicVeinAPIClient:
|
|
|
4297
4298
|
sort_column (str): Column to sort by (default: "policyName").
|
|
4298
4299
|
descending (bool): Sort descending if True (default: False).
|
|
4299
4300
|
page_size (int): Records per API call (default: 500).
|
|
4301
|
+
strict (bool): Raise on an answer with no list of policies, such as a null result or a
|
|
4302
|
+
response that is not JSON-RPC, rather than stopping the listing there. Without it,
|
|
4303
|
+
such an answer reads as no (more) policies, so a failed read looks like an empty one.
|
|
4300
4304
|
|
|
4301
4305
|
Returns:
|
|
4302
4306
|
List[Dict[str, Any]]: All matching alert policies.
|
|
4307
|
+
|
|
4308
|
+
Raises:
|
|
4309
|
+
ValueError: If ``strict`` and an answer has no list of policies.
|
|
4303
4310
|
"""
|
|
4304
|
-
return self._search_alert_policies(managed_networks, queries, sort_column, descending, page_size, strict=
|
|
4311
|
+
return self._search_alert_policies(managed_networks, queries, sort_column, descending, page_size, strict=strict)
|
|
4305
4312
|
|
|
4306
4313
|
def _search_alert_policies(
|
|
4307
4314
|
self,
|
|
@@ -4402,7 +4409,8 @@ class LogicVeinAPIClient:
|
|
|
4402
4409
|
A policy that alert triggers still use (:meth:`is_alert_policy_referenced`) may not be
|
|
4403
4410
|
deleted on its own: as in the web UI, which asks for an alternate policy to take those
|
|
4404
4411
|
triggers, ``reassign_policy_id`` must name another existing policy. Otherwise this
|
|
4405
|
-
raises before deleting anything.
|
|
4412
|
+
raises before deleting anything. The server then changes those triggers to name that
|
|
4413
|
+
policy, keeping their trigger IDs, so it reads as in use afterwards.
|
|
4406
4414
|
|
|
4407
4415
|
Calls Collection.deleteAlertPolicy with ``policyId`` and ``reassignPolicyId``, as the UI
|
|
4408
4416
|
does; the server refuses ``policyId`` alone. It answers true when it deletes the policy
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Tests for scripts/release/promote_pypi.py."""
|
|
2
|
+
|
|
3
|
+
import importlib.util
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
_PATH = Path(__file__).resolve().parent.parent / "scripts" / "release" / "promote_pypi.py"
|
|
9
|
+
_SPEC = importlib.util.spec_from_file_location("promote_pypi", _PATH)
|
|
10
|
+
assert _SPEC is not None and _SPEC.loader is not None, _PATH
|
|
11
|
+
promote = importlib.util.module_from_spec(_SPEC)
|
|
12
|
+
_SPEC.loader.exec_module(promote)
|
|
13
|
+
|
|
14
|
+
WHEEL, SDIST = "pkg-1.0-py3-none-any.whl", "pkg-1.0.tar.gz"
|
|
15
|
+
EXPECTED = {WHEEL: "aa", SDIST: "bb"}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.fixture
|
|
19
|
+
def pypi(monkeypatch):
|
|
20
|
+
"""Answer _published from a list of listings, and run a fake clock that sleep advances."""
|
|
21
|
+
clock = [0.0]
|
|
22
|
+
monkeypatch.setattr(promote.time, "monotonic", lambda: clock[0])
|
|
23
|
+
monkeypatch.setattr(promote.time, "sleep", lambda seconds: clock.__setitem__(0, clock[0] + seconds))
|
|
24
|
+
|
|
25
|
+
def serve(*listings):
|
|
26
|
+
answers = list(listings)
|
|
27
|
+
reads = []
|
|
28
|
+
|
|
29
|
+
def published(_version):
|
|
30
|
+
reads.append(clock[0])
|
|
31
|
+
return answers.pop(0) if len(answers) > 1 else answers[0]
|
|
32
|
+
|
|
33
|
+
monkeypatch.setattr(promote, "_published", published)
|
|
34
|
+
return reads
|
|
35
|
+
|
|
36
|
+
return serve
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_it_waits_until_every_file_is_listed(pypi):
|
|
40
|
+
# The 0.2.10 promotion: the version was listed with the wheel only, a second after both uploaded.
|
|
41
|
+
reads = pypi({}, {WHEEL: "aa"}, {WHEEL: "aa", SDIST: "bb"})
|
|
42
|
+
promote._verify_on_pypi("1.0", EXPECTED)
|
|
43
|
+
assert len(reads) == 3
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_a_file_never_listed_fails_after_the_timeout(pypi):
|
|
47
|
+
pypi({WHEEL: "aa"})
|
|
48
|
+
with pytest.raises(SystemExit, match="pkg-1.0.tar.gz: not listed on PyPI for 1.0 after 30s"):
|
|
49
|
+
promote._verify_on_pypi("1.0", EXPECTED, timeout=30)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_a_different_hash_fails_at_once(pypi):
|
|
53
|
+
reads = pypi({WHEEL: "aa", SDIST: "zz"})
|
|
54
|
+
with pytest.raises(SystemExit, match="PyPI has sha256=zz, expected bb"):
|
|
55
|
+
promote._verify_on_pypi("1.0", EXPECTED)
|
|
56
|
+
assert len(reads) == 1
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_a_different_hash_fails_at_once_while_another_file_is_not_listed_yet(pypi):
|
|
60
|
+
reads = pypi({WHEEL: "zz"})
|
|
61
|
+
with pytest.raises(SystemExit, match="PyPI has sha256=zz, expected aa"):
|
|
62
|
+
promote._verify_on_pypi("1.0", EXPECTED)
|
|
63
|
+
assert len(reads) == 1
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_a_retried_upload_skips_the_files_pypi_has(monkeypatch):
|
|
67
|
+
calls = []
|
|
68
|
+
monkeypatch.setattr(promote.subprocess, "run", lambda args, **_kwargs: calls.append(args))
|
|
69
|
+
promote._upload([Path("dist") / WHEEL])
|
|
70
|
+
assert "--skip-existing" in calls[0]
|
|
@@ -703,6 +703,22 @@ class TestAlertPolicies:
|
|
|
703
703
|
client, _ = connect({"Collection.searchAlertPolicies": None})
|
|
704
704
|
assert client.search_alert_policies() == []
|
|
705
705
|
|
|
706
|
+
@pytest.mark.parametrize("answer", [None, {}, {"policies": None}])
|
|
707
|
+
def test_a_strict_search_raises_on_an_answer_with_no_policies(self, connect, answer):
|
|
708
|
+
client, _ = connect({"Collection.searchAlertPolicies": answer})
|
|
709
|
+
with pytest.raises(ValueError):
|
|
710
|
+
client.search_alert_policies(strict=True)
|
|
711
|
+
|
|
712
|
+
def test_a_strict_search_raises_on_a_response_that_is_not_json_rpc(self, connect):
|
|
713
|
+
client, _ = connect()
|
|
714
|
+
with patch.object(client, "call", return_value="<html>login</html>"):
|
|
715
|
+
with pytest.raises(ValueError):
|
|
716
|
+
client.search_alert_policies(strict=True)
|
|
717
|
+
|
|
718
|
+
def test_a_strict_search_returns_what_it_reads(self, connect):
|
|
719
|
+
client, _ = connect({"Collection.searchAlertPolicies": {"policies": [{"policyId": 1}]}})
|
|
720
|
+
assert client.search_alert_policies(strict=True) == [{"policyId": 1}]
|
|
721
|
+
|
|
706
722
|
@pytest.mark.parametrize("answer", [True, False])
|
|
707
723
|
def test_a_reference_check_sends_the_id_and_returns_the_answer(self, connect, answer):
|
|
708
724
|
client, server = connect({"Collection.isAlertPolicyReferenced": answer})
|
lvi_api_client-0.2.9/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.2.9
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lvi_api_client-0.2.9 → lvi_api_client-0.2.11}/src/lvi_api_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|