-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Michał Bartoszkiewicz <[email protected]> GitOrigin-RevId: 24be4beadca59a176d0749fba5b0aa1048df4a16
- Loading branch information
1 parent
e04670c
commit 6fc1998
Showing
8 changed files
with
329 additions
and
80 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# import pathway.internals as pw | ||
import json | ||
import logging | ||
import os | ||
import re | ||
|
||
import pytest | ||
|
||
import pathway as pw | ||
from pathway.internals.config import _check_entitlements | ||
from pathway.tests.utils import run_all | ||
|
||
PATHWAY_LICENSES = json.loads(os.environ.get("PATHWAY_LICENSES", "{}")) | ||
|
||
|
||
def test_license_malformed(): | ||
pw.set_license_key(PATHWAY_LICENSES["malformed"]) | ||
with pytest.raises( | ||
RuntimeError, | ||
match=r"unable to validate license", | ||
): | ||
pw.run_all() | ||
|
||
|
||
def test_license_wrong_signature(): | ||
pw.set_license_key(PATHWAY_LICENSES["wrong-signature"]) | ||
with pytest.raises( | ||
RuntimeError, | ||
match=r"unable to validate license: license file is invalid", | ||
): | ||
pw.run_all() | ||
|
||
|
||
@pytest.mark.parametrize("license", ["default", "default-key"]) | ||
def test_license_default_key(license, caplog): | ||
caplog.set_level(level=logging.INFO) | ||
pw.set_license_key(PATHWAY_LICENSES[license]) | ||
run_all() | ||
assert "Telemetry enabled" in caplog.text | ||
assert "Monitoring server:" in caplog.text | ||
|
||
|
||
@pytest.mark.parametrize("license", ["default", "default-key"]) | ||
def test_license_default_key_insufficient_entitlements(license, caplog): | ||
pw.set_license_key(PATHWAY_LICENSES[license]) | ||
with pytest.raises( | ||
RuntimeError, | ||
match=re.escape( | ||
'one of the features you used ["XPACK-SPATIAL"] requires upgrading your Pathway license.' | ||
), | ||
): | ||
_check_entitlements("xpack-spatial") | ||
|
||
|
||
def test_license_enterprise(caplog): | ||
caplog.set_level(level=logging.INFO) | ||
pw.set_license_key(PATHWAY_LICENSES["enterprise-no-expire"]) | ||
|
||
_check_entitlements("xpack-spatial") | ||
run_all() | ||
|
||
assert "Telemetry enabled" not in caplog.text | ||
assert "Monitoring server:" in caplog.text | ||
|
||
|
||
def test_license_enterprise_expired(caplog): | ||
caplog.set_level(level=logging.INFO) | ||
pw.set_license_key(PATHWAY_LICENSES["enterprise-expired"]) | ||
|
||
_check_entitlements("xpack-spatial") | ||
run_all() | ||
|
||
assert ( | ||
"License has expired. Please renew to continue using the service" in caplog.text | ||
) | ||
assert "Telemetry enabled" not in caplog.text | ||
assert "Monitoring server:" in caplog.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.