licensing 0.54__tar.gz → 0.55__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.
- {licensing-0.54/licensing.egg-info → licensing-0.55}/PKG-INFO +2 -2
- {licensing-0.54 → licensing-0.55}/README.md +36 -36
- {licensing-0.54 → licensing-0.55}/licensing/methods.py +135 -0
- {licensing-0.54 → licensing-0.55/licensing.egg-info}/PKG-INFO +2 -2
- {licensing-0.54 → licensing-0.55}/setup.py +2 -2
- {licensing-0.54 → licensing-0.55}/tests/test_ai_usage_analytics.py +128 -128
- {licensing-0.54 → licensing-0.55}/LICENSE.txt +0 -0
- {licensing-0.54 → licensing-0.55}/LicenseFile.skm +0 -0
- {licensing-0.54 → licensing-0.55}/licensing/__init__.py +0 -0
- {licensing-0.54 → licensing-0.55}/licensing/internal.py +0 -0
- {licensing-0.54 → licensing-0.55}/licensing/models.py +0 -0
- {licensing-0.54 → licensing-0.55}/licensing.egg-info/SOURCES.txt +0 -0
- {licensing-0.54 → licensing-0.55}/licensing.egg-info/dependency_links.txt +0 -0
- {licensing-0.54 → licensing-0.55}/licensing.egg-info/top_level.txt +0 -0
- {licensing-0.54 → licensing-0.55}/setup.cfg +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: licensing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.55
|
|
4
4
|
Home-page: https://devolens.com
|
|
5
|
-
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/
|
|
5
|
+
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/v_55.tar.gz
|
|
6
6
|
Author: Cryptolens AB
|
|
7
7
|
Author-email: help@devolens.com
|
|
8
8
|
License: MIT
|
|
@@ -157,7 +157,7 @@ else:
|
|
|
157
157
|
print("License expires: " + str(license_key.expires))
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
### Create Trial Key (verified trial)
|
|
160
|
+
### Create Trial Key (verified trial)
|
|
161
161
|
|
|
162
162
|
#### Idea
|
|
163
163
|
|
|
@@ -198,41 +198,41 @@ else:
|
|
|
198
198
|
|
|
199
199
|
license_key = result[0]
|
|
200
200
|
print("Feature 1: " + str(license_key.f1))
|
|
201
|
-
print("License expires: " + str(license_key.expires))
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Usage analytics
|
|
205
|
-
|
|
206
|
-
The SDK can retrieve the aggregate usage analytics endpoints from the `AI` class. These methods return a tuple of `(items, message)`, where `items` is a list of dictionaries using the API's camelCase JSON field names.
|
|
207
|
-
|
|
208
|
-
```python
|
|
209
|
-
from licensing.methods import AI
|
|
210
|
-
|
|
211
|
-
result = AI.get_daily_aggregates(
|
|
212
|
-
token="ACCESS_TOKEN_WITH_USAGE_ANALYTICS_PERMISSION",
|
|
213
|
-
product_id=YOUR_PRODUCT_ID,
|
|
214
|
-
start="2026-05-01",
|
|
215
|
-
end="2026-05-31"
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
if result[0] == None:
|
|
219
|
-
print("An error occurred: {0}".format(result[1]))
|
|
220
|
-
else:
|
|
221
|
-
for aggregate in result[0]:
|
|
222
|
-
print(aggregate["date"], aggregate["totalRequestsLogged"])
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
Available usage analytics methods:
|
|
226
|
-
|
|
227
|
-
* `AI.get_daily_aggregates`
|
|
228
|
-
* `AI.get_daily_country_aggregates`
|
|
229
|
-
* `AI.get_key_usage_summaries`
|
|
230
|
-
* `AI.get_key_devices`
|
|
231
|
-
* `AI.get_license_activity_buckets`
|
|
232
|
-
|
|
233
|
-
### License server or custom endpoint
|
|
234
|
-
|
|
235
|
-
To forward requests to a local license server or a different API, you can set it using the `server_address` in HelperMethods, i.e.,
|
|
201
|
+
print("License expires: " + str(license_key.expires))
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Usage analytics
|
|
205
|
+
|
|
206
|
+
The SDK can retrieve the aggregate usage analytics endpoints from the `AI` class. These methods return a tuple of `(items, message)`, where `items` is a list of dictionaries using the API's camelCase JSON field names.
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from licensing.methods import AI
|
|
210
|
+
|
|
211
|
+
result = AI.get_daily_aggregates(
|
|
212
|
+
token="ACCESS_TOKEN_WITH_USAGE_ANALYTICS_PERMISSION",
|
|
213
|
+
product_id=YOUR_PRODUCT_ID,
|
|
214
|
+
start="2026-05-01",
|
|
215
|
+
end="2026-05-31"
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
if result[0] == None:
|
|
219
|
+
print("An error occurred: {0}".format(result[1]))
|
|
220
|
+
else:
|
|
221
|
+
for aggregate in result[0]:
|
|
222
|
+
print(aggregate["date"], aggregate["totalRequestsLogged"])
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Available usage analytics methods:
|
|
226
|
+
|
|
227
|
+
* `AI.get_daily_aggregates`
|
|
228
|
+
* `AI.get_daily_country_aggregates`
|
|
229
|
+
* `AI.get_key_usage_summaries`
|
|
230
|
+
* `AI.get_key_devices`
|
|
231
|
+
* `AI.get_license_activity_buckets`
|
|
232
|
+
|
|
233
|
+
### License server or custom endpoint
|
|
234
|
+
|
|
235
|
+
To forward requests to a local license server or a different API, you can set it using the `server_address` in HelperMethods, i.e.,
|
|
236
236
|
|
|
237
237
|
```python
|
|
238
238
|
HelperMethods.server_address = "http://localhost:8080/api/";
|
|
@@ -642,6 +642,10 @@ class AI:
|
|
|
642
642
|
else:
|
|
643
643
|
return (None, "Could not contact the server.")
|
|
644
644
|
|
|
645
|
+
# Reports need their summary and paging fields as well as the rows.
|
|
646
|
+
if result_field is None:
|
|
647
|
+
return (jobj, "")
|
|
648
|
+
|
|
645
649
|
return (jobj[result_field], "")
|
|
646
650
|
|
|
647
651
|
@staticmethod
|
|
@@ -756,6 +760,137 @@ class AI:
|
|
|
756
760
|
"Start": start,\
|
|
757
761
|
"End": end})
|
|
758
762
|
|
|
763
|
+
@staticmethod
|
|
764
|
+
def get_floating_capacity(token, product_id=0, start="", end="",
|
|
765
|
+
capacity_mode="exceeded", granularity="day",
|
|
766
|
+
page=1, limit=100):
|
|
767
|
+
"""
|
|
768
|
+
Retrieve excess or unused floating-license capacity by product and period.
|
|
769
|
+
Requires Usage Analytics permission. Use product_id=0 for all products
|
|
770
|
+
allowed by the token. capacity_mode is "exceeded" or "below", and
|
|
771
|
+
granularity is "day" or "30m".
|
|
772
|
+
|
|
773
|
+
Supply start and end together as inclusive UTC dates in yyyy-MM-dd
|
|
774
|
+
format, covering at most 90 days and not extending into the future.
|
|
775
|
+
Omit both for the last 7 UTC calendar days, including today.
|
|
776
|
+
page starts at 1; limit defaults to 100 and is capped at 1000 by the API.
|
|
777
|
+
|
|
778
|
+
Returns (report, message), or (None, message) on failure. report is the
|
|
779
|
+
full dictionary with camelCase fields, including periods, summary,
|
|
780
|
+
page, limit, total, returned, and generatedUtc. Check each period's
|
|
781
|
+
hasData before interpreting zero usage as observed data.
|
|
782
|
+
|
|
783
|
+
More docs: https://app.cryptolens.io/docs/api/v3/GetFloatingCapacity
|
|
784
|
+
"""
|
|
785
|
+
|
|
786
|
+
return AI.__get_usage_analytics("ai/GetFloatingCapacity", None, token, {
|
|
787
|
+
"ProductId": product_id,
|
|
788
|
+
"Start": start,
|
|
789
|
+
"End": end,
|
|
790
|
+
"CapacityMode": capacity_mode,
|
|
791
|
+
"Granularity": granularity,
|
|
792
|
+
"Page": page,
|
|
793
|
+
"Limit": limit})
|
|
794
|
+
|
|
795
|
+
@staticmethod
|
|
796
|
+
def get_floating_capacity_licenses(token, product_id, interval_start_utc,
|
|
797
|
+
capacity_mode="exceeded", page=1,
|
|
798
|
+
limit=100):
|
|
799
|
+
"""
|
|
800
|
+
Retrieve licenses contributing to excess or unused floating capacity.
|
|
801
|
+
Requires Usage Analytics permission. Returning customer names, company
|
|
802
|
+
names, and email addresses also requires Get Customers permission.
|
|
803
|
+
|
|
804
|
+
product_id is required. interval_start_utc is a non-future Unix timestamp
|
|
805
|
+
in seconds, aligned to a 30-minute UTC boundary. It can be taken from a
|
|
806
|
+
Get Floating Capacity period's worstIntervalStartUtc. capacity_mode is
|
|
807
|
+
"exceeded" or "below". page starts at 1; limit defaults to 100 and is
|
|
808
|
+
capped at 1000 by the API.
|
|
809
|
+
|
|
810
|
+
Returns (report, message), or (None, message) on failure. report is the
|
|
811
|
+
full dictionary with camelCase fields, including licenses, hasData,
|
|
812
|
+
page, limit, total, returned, and generatedUtc. An empty licenses list
|
|
813
|
+
can mean there is no finding or that the requested page is out of range.
|
|
814
|
+
|
|
815
|
+
More docs: https://app.cryptolens.io/docs/api/v3/GetFloatingCapacityLicenses
|
|
816
|
+
"""
|
|
817
|
+
|
|
818
|
+
return AI.__get_usage_analytics("ai/GetFloatingCapacityLicenses", None, token, {
|
|
819
|
+
"ProductId": product_id,
|
|
820
|
+
"IntervalStartUtc": interval_start_utc,
|
|
821
|
+
"CapacityMode": capacity_mode,
|
|
822
|
+
"Page": page,
|
|
823
|
+
"Limit": limit})
|
|
824
|
+
|
|
825
|
+
@staticmethod
|
|
826
|
+
def get_floating_capacity_history(token, product_id, key_id=0, key="",
|
|
827
|
+
start="", end="", page=1, limit=100):
|
|
828
|
+
"""
|
|
829
|
+
Retrieve a license's recorded floating usage and historical limits.
|
|
830
|
+
Requires Usage Analytics permission. Supply product_id and either
|
|
831
|
+
key_id or key. If both are supplied, they must identify the same
|
|
832
|
+
license in that product.
|
|
833
|
+
|
|
834
|
+
Supply start and end together as inclusive UTC dates in yyyy-MM-dd
|
|
835
|
+
format, covering at most 90 days and not extending into the future.
|
|
836
|
+
Omit both for the last 30 UTC calendar days, including today.
|
|
837
|
+
page starts at 1; limit defaults to 100 and is capped at 1000 by the API.
|
|
838
|
+
|
|
839
|
+
Returns (report, message), or (None, message) on failure. report is the
|
|
840
|
+
full dictionary with camelCase fields, including points, summary,
|
|
841
|
+
page, limit, total, returned, and generatedUtc. Points retain tracking
|
|
842
|
+
gaps, historical limits, and any available baseline. Use
|
|
843
|
+
report["summary"]["hasTrackedCapacityData"] to check for usable
|
|
844
|
+
tracked capacity, even when the requested page is empty.
|
|
845
|
+
|
|
846
|
+
More docs: https://app.cryptolens.io/docs/api/v3/GetFloatingCapacityHistory
|
|
847
|
+
"""
|
|
848
|
+
|
|
849
|
+
return AI.__get_usage_analytics("ai/GetFloatingCapacityHistory", None, token, {
|
|
850
|
+
"ProductId": product_id,
|
|
851
|
+
"KeyId": key_id,
|
|
852
|
+
"Key": key,
|
|
853
|
+
"Start": start,
|
|
854
|
+
"End": end,
|
|
855
|
+
"Page": page,
|
|
856
|
+
"Limit": limit})
|
|
857
|
+
|
|
858
|
+
@staticmethod
|
|
859
|
+
def get_expiring_licenses(token, product_id=0, window="7d", customer_id=None,
|
|
860
|
+
include_blocked_licenses=False, page=1, limit=100):
|
|
861
|
+
"""
|
|
862
|
+
Retrieve upcoming license expirations and a 7/14/30-day summary.
|
|
863
|
+
Requires Usage Analytics permission. Returning customer names, company
|
|
864
|
+
names, and email addresses also requires Get Customers permission.
|
|
865
|
+
|
|
866
|
+
Use product_id=0 for all products allowed by the token. window defaults
|
|
867
|
+
to "7d" and accepts a nonnegative integer with d, w, m, or y for days,
|
|
868
|
+
weeks, calendar months, or calendar years. A bare integer means days.
|
|
869
|
+
customer_id=None omits the customer filter; otherwise supply a positive
|
|
870
|
+
customer ID. Blocked licenses are excluded unless
|
|
871
|
+
include_blocked_licenses=True. page starts at 1; limit defaults to 100
|
|
872
|
+
and is capped at 1000 by the API.
|
|
873
|
+
|
|
874
|
+
Returns (report, message), or (None, message) on failure. report is the
|
|
875
|
+
full dictionary with camelCase fields, including licenses, summary,
|
|
876
|
+
expiresBeforeUtc, page, limit, total, returned, and generatedUtc.
|
|
877
|
+
The summary respects the filters but is independent of window and page.
|
|
878
|
+
|
|
879
|
+
More docs: https://app.cryptolens.io/docs/api/v3/GetExpiringLicenses
|
|
880
|
+
"""
|
|
881
|
+
|
|
882
|
+
params = {
|
|
883
|
+
"ProductId": product_id,
|
|
884
|
+
"Window": window,
|
|
885
|
+
"IncludeBlockedLicenses": include_blocked_licenses,
|
|
886
|
+
"Page": page,
|
|
887
|
+
"Limit": limit}
|
|
888
|
+
|
|
889
|
+
if customer_id is not None:
|
|
890
|
+
params["CustomerId"] = customer_id
|
|
891
|
+
|
|
892
|
+
return AI.__get_usage_analytics("ai/GetExpiringLicenses", None, token, params)
|
|
893
|
+
|
|
759
894
|
@staticmethod
|
|
760
895
|
def get_web_api_log(token, product_id = 0, key = "", machine_code="", friendly_name = "",\
|
|
761
896
|
limit = 10, starting_after = 0, ending_before=0, order_by=""):
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: licensing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.55
|
|
4
4
|
Home-page: https://devolens.com
|
|
5
|
-
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/
|
|
5
|
+
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/v_55.tar.gz
|
|
6
6
|
Author: Cryptolens AB
|
|
7
7
|
Author-email: help@devolens.com
|
|
8
8
|
License: MIT
|
|
@@ -3,7 +3,7 @@ from setuptools import setup
|
|
|
3
3
|
setup(
|
|
4
4
|
name = 'licensing', # How you named your package folder (MyLib)
|
|
5
5
|
packages = ['licensing'], # Chose the same as "name"
|
|
6
|
-
version = '0.
|
|
6
|
+
version = '0.55', # Start with a small number and increase it with every change you make
|
|
7
7
|
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
|
|
8
8
|
#description_file = 'Client library for Cryptolens licensing Web API.', # Give a short description about your library
|
|
9
9
|
long_description = 'Client library for Devolens (formerly Cryptolens) Web API (software licensing).',
|
|
@@ -11,7 +11,7 @@ setup(
|
|
|
11
11
|
author = 'Cryptolens AB', # Type in your name
|
|
12
12
|
author_email = 'help@devolens.com', # Type in your E-Mail
|
|
13
13
|
url = 'https://devolens.com', # Provide either the link to your github or to your website
|
|
14
|
-
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/
|
|
14
|
+
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_55.tar.gz',
|
|
15
15
|
project_urls={ # optional, shows on PyPI
|
|
16
16
|
"Source": "https://github.com/Cryptolens/cryptolens-python",
|
|
17
17
|
"Tracker": "https://github.com/Cryptolens/cryptolens-python/issues",
|
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import unittest
|
|
3
|
-
|
|
4
|
-
from licensing.internal import HelperMethods
|
|
5
|
-
from licensing.methods import AI
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class AIUsageAnalyticsTests(unittest.TestCase):
|
|
9
|
-
|
|
10
|
-
def _assert_usage_analytics_call(self, call, expected_endpoint, expected_field, expected_params):
|
|
11
|
-
original_send_request = HelperMethods.send_request
|
|
12
|
-
captured = {}
|
|
13
|
-
|
|
14
|
-
def fake_send_request(endpoint, params):
|
|
15
|
-
captured["endpoint"] = endpoint
|
|
16
|
-
captured["params"] = params
|
|
17
|
-
return json.dumps({
|
|
18
|
-
"result": 0,
|
|
19
|
-
"message": None,
|
|
20
|
-
expected_field: [{"id": 1}]
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
try:
|
|
24
|
-
HelperMethods.send_request = fake_send_request
|
|
25
|
-
result = call()
|
|
26
|
-
finally:
|
|
27
|
-
HelperMethods.send_request = original_send_request
|
|
28
|
-
|
|
29
|
-
self.assertEqual(result, ([{"id": 1}], ""))
|
|
30
|
-
self.assertEqual(captured["endpoint"], expected_endpoint)
|
|
31
|
-
|
|
32
|
-
for key, value in expected_params.items():
|
|
33
|
-
self.assertEqual(captured["params"][key], value)
|
|
34
|
-
|
|
35
|
-
def test_get_daily_aggregates(self):
|
|
36
|
-
self._assert_usage_analytics_call(
|
|
37
|
-
lambda: AI.get_daily_aggregates(
|
|
38
|
-
token="token",
|
|
39
|
-
product_id=123,
|
|
40
|
-
limit=25,
|
|
41
|
-
starting_after=10,
|
|
42
|
-
ending_before=20,
|
|
43
|
-
start="2026-05-01",
|
|
44
|
-
end="2026-05-31"
|
|
45
|
-
),
|
|
46
|
-
"ai/GetDailyAggregates",
|
|
47
|
-
"aggregates",
|
|
48
|
-
{
|
|
49
|
-
"token": "token",
|
|
50
|
-
"ProductId": 123,
|
|
51
|
-
"Limit": 25,
|
|
52
|
-
"StartingAfter": 10,
|
|
53
|
-
"EndingBefore": 20,
|
|
54
|
-
"Start": "2026-05-01",
|
|
55
|
-
"End": "2026-05-31"
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
def test_get_daily_country_aggregates(self):
|
|
59
|
-
self._assert_usage_analytics_call(
|
|
60
|
-
lambda: AI.get_daily_country_aggregates(
|
|
61
|
-
token="token",
|
|
62
|
-
product_id=123,
|
|
63
|
-
country_code="SE"
|
|
64
|
-
),
|
|
65
|
-
"ai/GetDailyCountryAggregates",
|
|
66
|
-
"aggregates",
|
|
67
|
-
{
|
|
68
|
-
"token": "token",
|
|
69
|
-
"ProductId": 123,
|
|
70
|
-
"CountryCode": "SE"
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
def test_get_key_usage_summaries(self):
|
|
74
|
-
self._assert_usage_analytics_call(
|
|
75
|
-
lambda: AI.get_key_usage_summaries(
|
|
76
|
-
token="token",
|
|
77
|
-
product_id=123,
|
|
78
|
-
key_id=456,
|
|
79
|
-
key="AAAA-BBBB-CCCC-DDDD"
|
|
80
|
-
),
|
|
81
|
-
"ai/GetKeyUsageSummaries",
|
|
82
|
-
"summaries",
|
|
83
|
-
{
|
|
84
|
-
"token": "token",
|
|
85
|
-
"ProductId": 123,
|
|
86
|
-
"KeyId": 456,
|
|
87
|
-
"Key": "AAAA-BBBB-CCCC-DDDD"
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
def test_get_key_devices(self):
|
|
91
|
-
self._assert_usage_analytics_call(
|
|
92
|
-
lambda: AI.get_key_devices(
|
|
93
|
-
token="token",
|
|
94
|
-
product_id=123,
|
|
95
|
-
key_id=456,
|
|
96
|
-
machine_code="MACHINE-1"
|
|
97
|
-
),
|
|
98
|
-
"ai/GetKeyDevices",
|
|
99
|
-
"devices",
|
|
100
|
-
{
|
|
101
|
-
"token": "token",
|
|
102
|
-
"ProductId": 123,
|
|
103
|
-
"KeyId": 456,
|
|
104
|
-
"MachineCode": "MACHINE-1"
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
def test_get_license_activity_buckets(self):
|
|
108
|
-
self._assert_usage_analytics_call(
|
|
109
|
-
lambda: AI.get_license_activity_buckets(
|
|
110
|
-
token="token",
|
|
111
|
-
product_id=123,
|
|
112
|
-
key_id=456,
|
|
113
|
-
key="AAAA-BBBB-CCCC-DDDD",
|
|
114
|
-
machine_code="MACHINE-1"
|
|
115
|
-
),
|
|
116
|
-
"ai/GetLicenseActivityBuckets",
|
|
117
|
-
"buckets",
|
|
118
|
-
{
|
|
119
|
-
"token": "token",
|
|
120
|
-
"ProductId": 123,
|
|
121
|
-
"KeyId": 456,
|
|
122
|
-
"Key": "AAAA-BBBB-CCCC-DDDD",
|
|
123
|
-
"MachineCode": "MACHINE-1"
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if __name__ == "__main__":
|
|
128
|
-
unittest.main()
|
|
1
|
+
import json
|
|
2
|
+
import unittest
|
|
3
|
+
|
|
4
|
+
from licensing.internal import HelperMethods
|
|
5
|
+
from licensing.methods import AI
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AIUsageAnalyticsTests(unittest.TestCase):
|
|
9
|
+
|
|
10
|
+
def _assert_usage_analytics_call(self, call, expected_endpoint, expected_field, expected_params):
|
|
11
|
+
original_send_request = HelperMethods.send_request
|
|
12
|
+
captured = {}
|
|
13
|
+
|
|
14
|
+
def fake_send_request(endpoint, params):
|
|
15
|
+
captured["endpoint"] = endpoint
|
|
16
|
+
captured["params"] = params
|
|
17
|
+
return json.dumps({
|
|
18
|
+
"result": 0,
|
|
19
|
+
"message": None,
|
|
20
|
+
expected_field: [{"id": 1}]
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
try:
|
|
24
|
+
HelperMethods.send_request = fake_send_request
|
|
25
|
+
result = call()
|
|
26
|
+
finally:
|
|
27
|
+
HelperMethods.send_request = original_send_request
|
|
28
|
+
|
|
29
|
+
self.assertEqual(result, ([{"id": 1}], ""))
|
|
30
|
+
self.assertEqual(captured["endpoint"], expected_endpoint)
|
|
31
|
+
|
|
32
|
+
for key, value in expected_params.items():
|
|
33
|
+
self.assertEqual(captured["params"][key], value)
|
|
34
|
+
|
|
35
|
+
def test_get_daily_aggregates(self):
|
|
36
|
+
self._assert_usage_analytics_call(
|
|
37
|
+
lambda: AI.get_daily_aggregates(
|
|
38
|
+
token="token",
|
|
39
|
+
product_id=123,
|
|
40
|
+
limit=25,
|
|
41
|
+
starting_after=10,
|
|
42
|
+
ending_before=20,
|
|
43
|
+
start="2026-05-01",
|
|
44
|
+
end="2026-05-31"
|
|
45
|
+
),
|
|
46
|
+
"ai/GetDailyAggregates",
|
|
47
|
+
"aggregates",
|
|
48
|
+
{
|
|
49
|
+
"token": "token",
|
|
50
|
+
"ProductId": 123,
|
|
51
|
+
"Limit": 25,
|
|
52
|
+
"StartingAfter": 10,
|
|
53
|
+
"EndingBefore": 20,
|
|
54
|
+
"Start": "2026-05-01",
|
|
55
|
+
"End": "2026-05-31"
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
def test_get_daily_country_aggregates(self):
|
|
59
|
+
self._assert_usage_analytics_call(
|
|
60
|
+
lambda: AI.get_daily_country_aggregates(
|
|
61
|
+
token="token",
|
|
62
|
+
product_id=123,
|
|
63
|
+
country_code="SE"
|
|
64
|
+
),
|
|
65
|
+
"ai/GetDailyCountryAggregates",
|
|
66
|
+
"aggregates",
|
|
67
|
+
{
|
|
68
|
+
"token": "token",
|
|
69
|
+
"ProductId": 123,
|
|
70
|
+
"CountryCode": "SE"
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
def test_get_key_usage_summaries(self):
|
|
74
|
+
self._assert_usage_analytics_call(
|
|
75
|
+
lambda: AI.get_key_usage_summaries(
|
|
76
|
+
token="token",
|
|
77
|
+
product_id=123,
|
|
78
|
+
key_id=456,
|
|
79
|
+
key="AAAA-BBBB-CCCC-DDDD"
|
|
80
|
+
),
|
|
81
|
+
"ai/GetKeyUsageSummaries",
|
|
82
|
+
"summaries",
|
|
83
|
+
{
|
|
84
|
+
"token": "token",
|
|
85
|
+
"ProductId": 123,
|
|
86
|
+
"KeyId": 456,
|
|
87
|
+
"Key": "AAAA-BBBB-CCCC-DDDD"
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
def test_get_key_devices(self):
|
|
91
|
+
self._assert_usage_analytics_call(
|
|
92
|
+
lambda: AI.get_key_devices(
|
|
93
|
+
token="token",
|
|
94
|
+
product_id=123,
|
|
95
|
+
key_id=456,
|
|
96
|
+
machine_code="MACHINE-1"
|
|
97
|
+
),
|
|
98
|
+
"ai/GetKeyDevices",
|
|
99
|
+
"devices",
|
|
100
|
+
{
|
|
101
|
+
"token": "token",
|
|
102
|
+
"ProductId": 123,
|
|
103
|
+
"KeyId": 456,
|
|
104
|
+
"MachineCode": "MACHINE-1"
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
def test_get_license_activity_buckets(self):
|
|
108
|
+
self._assert_usage_analytics_call(
|
|
109
|
+
lambda: AI.get_license_activity_buckets(
|
|
110
|
+
token="token",
|
|
111
|
+
product_id=123,
|
|
112
|
+
key_id=456,
|
|
113
|
+
key="AAAA-BBBB-CCCC-DDDD",
|
|
114
|
+
machine_code="MACHINE-1"
|
|
115
|
+
),
|
|
116
|
+
"ai/GetLicenseActivityBuckets",
|
|
117
|
+
"buckets",
|
|
118
|
+
{
|
|
119
|
+
"token": "token",
|
|
120
|
+
"ProductId": 123,
|
|
121
|
+
"KeyId": 456,
|
|
122
|
+
"Key": "AAAA-BBBB-CCCC-DDDD",
|
|
123
|
+
"MachineCode": "MACHINE-1"
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
if __name__ == "__main__":
|
|
128
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|