encommon 0.11.0__tar.gz → 0.12.0__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.
- {encommon-0.11.0/encommon.egg-info → encommon-0.12.0}/PKG-INFO +2 -1
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/config.py +4 -8
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/logger.py +3 -2
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/test/test_logger.py +1 -1
- {encommon-0.11.0 → encommon-0.12.0}/encommon/crypts/crypts.py +51 -2
- {encommon-0.11.0 → encommon-0.12.0}/encommon/crypts/params.py +1 -1
- {encommon-0.11.0 → encommon-0.12.0}/encommon/crypts/test/test_crypts.py +56 -1
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/params.py +3 -3
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/test_timers.py +44 -49
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/test_windows.py +53 -65
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/timers.py +116 -85
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/windows.py +137 -103
- encommon-0.12.0/encommon/version.txt +1 -0
- {encommon-0.11.0 → encommon-0.12.0/encommon.egg-info}/PKG-INFO +2 -1
- {encommon-0.11.0 → encommon-0.12.0}/encommon.egg-info/requires.txt +1 -0
- {encommon-0.11.0 → encommon-0.12.0}/reqs-install.txt +1 -0
- encommon-0.11.0/encommon/version.txt +0 -1
- {encommon-0.11.0 → encommon-0.12.0}/LICENSE +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/MANIFEST.in +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/README.md +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/files.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/params.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/paths.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/test/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/test/test_config.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/test/test_files.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/test/test_paths.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/test/test_utils.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/config/utils.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/conftest.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/crypts/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/crypts/hashes.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/crypts/test/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/crypts/test/test_hashes.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/py.typed +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/common.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/duration.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/parse.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/test_duration.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/test_params.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/test_parse.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/test_timer.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/test_times.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/test_utils.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/test/test_window.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/timer.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/times.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/utils.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/times/window.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/dicts.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/empty.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/notate.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/strings.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/test/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/test/test_dicts.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/test/test_empty.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/test/test_notate.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/types/test/test_strings.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/common.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/files.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/match.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/paths.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/sample.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/stdout.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/test/__init__.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/test/test_files.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/test/test_match.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/test/test_paths.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/test/test_sample.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon/utils/test/test_stdout.py +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon.egg-info/SOURCES.txt +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon.egg-info/dependency_links.txt +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/encommon.egg-info/top_level.txt +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/pyproject.toml +0 -0
- {encommon-0.11.0 → encommon-0.12.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: encommon
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.12.0
|
4
4
|
Summary: Enasis Network Common Library
|
5
5
|
License: MIT
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
@@ -15,6 +15,7 @@ Requires-Dist: pydantic
|
|
15
15
|
Requires-Dist: python-dateutil
|
16
16
|
Requires-Dist: pyyaml
|
17
17
|
Requires-Dist: snaptime
|
18
|
+
Requires-Dist: sqlalchemy
|
18
19
|
|
19
20
|
# Enasis Network Common Library
|
20
21
|
|
@@ -217,11 +217,10 @@ class Config:
|
|
217
217
|
if self.__logger is not None:
|
218
218
|
return self.__logger
|
219
219
|
|
220
|
-
|
220
|
+
logger = Logger(
|
221
221
|
self.params.enlogger)
|
222
222
|
|
223
|
-
self.__logger =
|
224
|
-
Logger(params=enlogger))
|
223
|
+
self.__logger = logger
|
225
224
|
|
226
225
|
return self.__logger
|
227
226
|
|
@@ -239,12 +238,9 @@ class Config:
|
|
239
238
|
if self.__crypts is not None:
|
240
239
|
return self.__crypts
|
241
240
|
|
242
|
-
|
241
|
+
crypts = Crypts(
|
243
242
|
self.params.encrypts)
|
244
243
|
|
245
|
-
|
246
|
-
|
247
|
-
self.__crypts = (
|
248
|
-
Crypts(params=encrypts))
|
244
|
+
self.__crypts = crypts
|
249
245
|
|
250
246
|
return self.__crypts
|
@@ -7,6 +7,7 @@ is permitted, for more information consult the project license file.
|
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
+
from copy import deepcopy
|
10
11
|
from json import dumps
|
11
12
|
from logging import CRITICAL
|
12
13
|
from logging import DEBUG
|
@@ -337,11 +338,11 @@ class Logger:
|
|
337
338
|
|
338
339
|
def __init__(
|
339
340
|
self,
|
341
|
+
params: Optional['LoggerParams'] = None,
|
340
342
|
*,
|
341
343
|
stdo_level: Optional[LOGLEVELS] = None,
|
342
344
|
file_level: Optional[LOGLEVELS] = None,
|
343
345
|
file_path: Optional[str | Path] = None,
|
344
|
-
params: Optional['LoggerParams'] = None,
|
345
346
|
) -> None:
|
346
347
|
"""
|
347
348
|
Initialize instance for class using provided parameters.
|
@@ -355,7 +356,7 @@ class Logger:
|
|
355
356
|
file_level=file_level,
|
356
357
|
file_path=file_path)
|
357
358
|
|
358
|
-
self.__params = params
|
359
|
+
self.__params = deepcopy(params)
|
359
360
|
|
360
361
|
stdo_level = params.stdo_level
|
361
362
|
file_level = params.file_level
|
@@ -7,9 +7,11 @@ is permitted, for more information consult the project license file.
|
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
+
from copy import deepcopy
|
10
11
|
from re import compile
|
11
12
|
from re import match as re_match
|
12
13
|
from re import sub as re_sub
|
14
|
+
from typing import Optional
|
13
15
|
from typing import TYPE_CHECKING
|
14
16
|
|
15
17
|
from cryptography.fernet import Fernet
|
@@ -17,6 +19,7 @@ from cryptography.fernet import Fernet
|
|
17
19
|
from ..types.strings import SEMPTY
|
18
20
|
|
19
21
|
if TYPE_CHECKING:
|
22
|
+
from .params import CryptParams
|
20
23
|
from .params import CryptsParams
|
21
24
|
|
22
25
|
|
@@ -53,13 +56,18 @@ class Crypts:
|
|
53
56
|
|
54
57
|
def __init__(
|
55
58
|
self,
|
56
|
-
params: 'CryptsParams',
|
59
|
+
params: Optional['CryptsParams'] = None,
|
57
60
|
) -> None:
|
58
61
|
"""
|
59
62
|
Initialize instance for class using provided parameters.
|
60
63
|
"""
|
61
64
|
|
62
|
-
|
65
|
+
from .params import CryptsParams
|
66
|
+
|
67
|
+
if params is None:
|
68
|
+
params = CryptsParams()
|
69
|
+
|
70
|
+
self.__params = deepcopy(params)
|
63
71
|
|
64
72
|
|
65
73
|
@property
|
@@ -90,6 +98,9 @@ class Crypts:
|
|
90
98
|
|
91
99
|
phrases = self.params.phrases
|
92
100
|
|
101
|
+
if unique not in phrases:
|
102
|
+
raise ValueError('unique')
|
103
|
+
|
93
104
|
phrase = phrases[unique].phrase
|
94
105
|
|
95
106
|
encrypt = (
|
@@ -134,6 +145,44 @@ class Crypts:
|
|
134
145
|
.decode())
|
135
146
|
|
136
147
|
|
148
|
+
def create(
|
149
|
+
self,
|
150
|
+
unique: str,
|
151
|
+
params: 'CryptParams',
|
152
|
+
) -> None:
|
153
|
+
"""
|
154
|
+
Create a new phrase using the provided input parameters.
|
155
|
+
|
156
|
+
:param unique: Unique identifier of mapping passphrase.
|
157
|
+
:param params: Parameters for instantiating the instance.
|
158
|
+
"""
|
159
|
+
|
160
|
+
phrases = self.params.phrases
|
161
|
+
|
162
|
+
if unique in phrases:
|
163
|
+
raise ValueError('unique')
|
164
|
+
|
165
|
+
phrases[unique] = params
|
166
|
+
|
167
|
+
|
168
|
+
def delete(
|
169
|
+
self,
|
170
|
+
unique: str,
|
171
|
+
) -> None:
|
172
|
+
"""
|
173
|
+
Delete the phrase from the internal dictionary reference.
|
174
|
+
|
175
|
+
:param unique: Unique identifier of mapping passphrase.
|
176
|
+
"""
|
177
|
+
|
178
|
+
phrases = self.params.phrases
|
179
|
+
|
180
|
+
if unique not in phrases:
|
181
|
+
raise ValueError('unique')
|
182
|
+
|
183
|
+
del phrases[unique]
|
184
|
+
|
185
|
+
|
137
186
|
@classmethod
|
138
187
|
def keygen(
|
139
188
|
cls: object,
|
@@ -14,6 +14,7 @@ from pytest import mark
|
|
14
14
|
from pytest import raises
|
15
15
|
|
16
16
|
from ..crypts import Crypts
|
17
|
+
from ..params import CryptParams
|
17
18
|
from ..params import CryptsParams
|
18
19
|
from ...types import inrepr
|
19
20
|
from ...types import instr
|
@@ -35,7 +36,7 @@ def crypts() -> Crypts:
|
|
35
36
|
params = CryptsParams(
|
36
37
|
phrases=source)
|
37
38
|
|
38
|
-
return Crypts(params
|
39
|
+
return Crypts(params)
|
39
40
|
|
40
41
|
|
41
42
|
|
@@ -103,6 +104,28 @@ def test_Crypts_iterate(
|
|
103
104
|
|
104
105
|
|
105
106
|
|
107
|
+
def test_Crypts_cover(
|
108
|
+
crypts: Crypts,
|
109
|
+
) -> None:
|
110
|
+
"""
|
111
|
+
Perform various tests associated with relevant routines.
|
112
|
+
|
113
|
+
:param crypts: Primary class instance for the encryption.
|
114
|
+
"""
|
115
|
+
|
116
|
+
|
117
|
+
crypts = Crypts()
|
118
|
+
|
119
|
+
|
120
|
+
params = CryptParams(
|
121
|
+
phrase=Crypts.keygen())
|
122
|
+
|
123
|
+
crypts.create('testing', params)
|
124
|
+
|
125
|
+
crypts.delete('testing')
|
126
|
+
|
127
|
+
|
128
|
+
|
106
129
|
def test_Crypts_raises(
|
107
130
|
crypts: Crypts,
|
108
131
|
) -> None:
|
@@ -113,6 +136,16 @@ def test_Crypts_raises(
|
|
113
136
|
"""
|
114
137
|
|
115
138
|
|
139
|
+
_raises = raises(ValueError)
|
140
|
+
|
141
|
+
with _raises as reason:
|
142
|
+
crypts.encrypt('foo', 'dne')
|
143
|
+
|
144
|
+
_reason = str(reason.value)
|
145
|
+
|
146
|
+
assert _reason == 'unique'
|
147
|
+
|
148
|
+
|
116
149
|
_raises = raises(ValueError)
|
117
150
|
|
118
151
|
with _raises as reason:
|
@@ -132,3 +165,25 @@ def test_Crypts_raises(
|
|
132
165
|
_reason = str(reason.value)
|
133
166
|
|
134
167
|
assert _reason == 'version'
|
168
|
+
|
169
|
+
|
170
|
+
_raises = raises(ValueError)
|
171
|
+
|
172
|
+
params = CryptParams(phrase='foo')
|
173
|
+
|
174
|
+
with _raises as reason:
|
175
|
+
crypts.create('default', params)
|
176
|
+
|
177
|
+
_reason = str(reason.value)
|
178
|
+
|
179
|
+
assert _reason == 'unique'
|
180
|
+
|
181
|
+
|
182
|
+
_raises = raises(ValueError)
|
183
|
+
|
184
|
+
with _raises as reason:
|
185
|
+
crypts.delete('dne')
|
186
|
+
|
187
|
+
_reason = str(reason.value)
|
188
|
+
|
189
|
+
assert _reason == 'unique'
|
@@ -68,7 +68,7 @@ class TimersParams(BaseModel, extra='forbid'):
|
|
68
68
|
Parameter is picked up by autodoc, please ignore.
|
69
69
|
"""
|
70
70
|
|
71
|
-
timers: dict[str, TimerParams]
|
71
|
+
timers: dict[str, TimerParams] = {}
|
72
72
|
|
73
73
|
|
74
74
|
|
@@ -117,7 +117,7 @@ class WindowParams(BaseModel, extra='forbid'):
|
|
117
117
|
stop = Times(stop)
|
118
118
|
|
119
119
|
if anchor is not None:
|
120
|
-
anchor = Times(
|
120
|
+
anchor = Times(anchor)
|
121
121
|
|
122
122
|
if delay is not None:
|
123
123
|
delay = float(delay)
|
@@ -152,4 +152,4 @@ class WindowsParams(BaseModel, extra='forbid'):
|
|
152
152
|
Parameter is picked up by autodoc, please ignore.
|
153
153
|
"""
|
154
154
|
|
155
|
-
windows: dict[str, WindowParams]
|
155
|
+
windows: dict[str, WindowParams] = {}
|
@@ -8,6 +8,7 @@ is permitted, for more information consult the project license file.
|
|
8
8
|
|
9
9
|
|
10
10
|
from pathlib import Path
|
11
|
+
from time import sleep
|
11
12
|
from typing import Any
|
12
13
|
|
13
14
|
from pytest import fixture
|
@@ -16,6 +17,7 @@ from pytest import raises
|
|
16
17
|
from ..params import TimerParams
|
17
18
|
from ..params import TimersParams
|
18
19
|
from ..timers import Timers
|
20
|
+
from ..timers import TimersTable
|
19
21
|
from ..times import Times
|
20
22
|
from ...types import inrepr
|
21
23
|
from ...types import instr
|
@@ -33,40 +35,45 @@ def timers(
|
|
33
35
|
:returns: Newly constructed instance of related class.
|
34
36
|
"""
|
35
37
|
|
38
|
+
|
36
39
|
source: dict[str, Any] = {
|
37
40
|
'one': {'timer': 1},
|
38
41
|
'two': {'timer': 1}}
|
39
42
|
|
43
|
+
|
40
44
|
params = TimersParams(
|
41
45
|
timers=source)
|
42
46
|
|
47
|
+
store = (
|
48
|
+
f'sqlite:///{tmp_path}'
|
49
|
+
'/cache.db')
|
50
|
+
|
43
51
|
timers = Timers(
|
44
52
|
params,
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
sqlite.commit()
|
53
|
+
store=store)
|
54
|
+
|
55
|
+
session = timers.store_session
|
56
|
+
|
57
|
+
|
58
|
+
timer = TimersTable(
|
59
|
+
group='default',
|
60
|
+
unique='two',
|
61
|
+
update='1970-01-01T00:00:00Z')
|
62
|
+
|
63
|
+
session.add(timer)
|
64
|
+
|
65
|
+
session.commit()
|
66
|
+
|
67
|
+
|
68
|
+
timer = TimersTable(
|
69
|
+
group='default',
|
70
|
+
unique='tre',
|
71
|
+
update='1970-01-01T00:00:00Z')
|
72
|
+
|
73
|
+
session.add(timer)
|
74
|
+
|
75
|
+
session.commit()
|
76
|
+
|
70
77
|
|
71
78
|
timers.load_children()
|
72
79
|
|
@@ -88,10 +95,10 @@ def test_Timers(
|
|
88
95
|
|
89
96
|
assert attrs == [
|
90
97
|
'_Timers__params',
|
91
|
-
'
|
92
|
-
'_Timers__file',
|
93
|
-
'_Timers__table',
|
98
|
+
'_Timers__store',
|
94
99
|
'_Timers__group',
|
100
|
+
'_Timers__store_engine',
|
101
|
+
'_Timers__store_session',
|
95
102
|
'_Timers__timers']
|
96
103
|
|
97
104
|
|
@@ -108,13 +115,13 @@ def test_Timers(
|
|
108
115
|
|
109
116
|
assert timers.params is not None
|
110
117
|
|
111
|
-
assert timers.
|
118
|
+
assert timers.store[:6] == 'sqlite'
|
112
119
|
|
113
|
-
assert timers.
|
120
|
+
assert timers.group == 'default'
|
114
121
|
|
115
|
-
assert timers.
|
122
|
+
assert timers.store_engine is not None
|
116
123
|
|
117
|
-
assert timers.
|
124
|
+
assert timers.store_session is not None
|
118
125
|
|
119
126
|
assert len(timers.children) == 2
|
120
127
|
|
@@ -140,35 +147,23 @@ def test_Timers_cover(
|
|
140
147
|
"""
|
141
148
|
|
142
149
|
|
143
|
-
assert not timers.ready('one')
|
144
|
-
|
145
150
|
assert timers.ready('two')
|
146
151
|
|
147
|
-
|
148
152
|
timers.update('two', 'now')
|
149
153
|
|
150
154
|
assert not timers.ready('two')
|
151
155
|
|
152
|
-
timers.load_children()
|
153
|
-
|
154
|
-
assert timers.ready('two')
|
155
|
-
|
156
|
-
|
157
|
-
timers.update('two', 'now')
|
158
156
|
|
159
|
-
|
157
|
+
timers = Timers()
|
160
158
|
|
161
|
-
timers.save_children()
|
162
|
-
timers.load_children()
|
163
159
|
|
164
|
-
|
160
|
+
params = TimerParams(timer=1)
|
165
161
|
|
162
|
+
timers.create('fur', params)
|
166
163
|
|
167
|
-
|
168
|
-
timer=1,
|
169
|
-
start='-1s')
|
164
|
+
assert not timers.ready('fur')
|
170
165
|
|
171
|
-
|
166
|
+
sleep(1)
|
172
167
|
|
173
168
|
assert timers.ready('fur')
|
174
169
|
|
@@ -8,6 +8,7 @@ is permitted, for more information consult the project license file.
|
|
8
8
|
|
9
9
|
|
10
10
|
from pathlib import Path
|
11
|
+
from time import sleep
|
11
12
|
from typing import Any
|
12
13
|
|
13
14
|
from pytest import fixture
|
@@ -16,6 +17,7 @@ from pytest import raises
|
|
16
17
|
from ..params import WindowParams
|
17
18
|
from ..params import WindowsParams
|
18
19
|
from ..windows import Windows
|
20
|
+
from ..windows import WindowsTable
|
19
21
|
from ...types import inrepr
|
20
22
|
from ...types import instr
|
21
23
|
|
@@ -32,6 +34,7 @@ def windows(
|
|
32
34
|
:returns: Newly constructed instance of related class.
|
33
35
|
"""
|
34
36
|
|
37
|
+
|
35
38
|
source: dict[str, Any] = {
|
36
39
|
'one': WindowParams(
|
37
40
|
window='* * * * *',
|
@@ -44,46 +47,46 @@ def windows(
|
|
44
47
|
stop=620,
|
45
48
|
delay=10)}
|
46
49
|
|
50
|
+
|
47
51
|
params = WindowsParams(
|
48
52
|
windows=source)
|
49
53
|
|
54
|
+
store = (
|
55
|
+
f'sqlite:///{tmp_path}'
|
56
|
+
'/cache.db')
|
57
|
+
|
50
58
|
windows = Windows(
|
51
59
|
params,
|
52
60
|
start=310,
|
53
61
|
stop=610,
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
"1970-01-01T00:07:00Z",
|
83
|
-
"1970-01-01T01:00:00Z")
|
84
|
-
""") # noqa: LIT003
|
85
|
-
|
86
|
-
sqlite.commit()
|
62
|
+
store=store)
|
63
|
+
|
64
|
+
session = windows.store_session
|
65
|
+
|
66
|
+
|
67
|
+
window = WindowsTable(
|
68
|
+
group='default',
|
69
|
+
unique='two',
|
70
|
+
last='1970-01-01T00:06:00Z',
|
71
|
+
next='1970-01-01T00:07:00Z',
|
72
|
+
update='1970-01-01T01:00:00Z')
|
73
|
+
|
74
|
+
session.add(window)
|
75
|
+
|
76
|
+
session.commit()
|
77
|
+
|
78
|
+
|
79
|
+
window = WindowsTable(
|
80
|
+
group='default',
|
81
|
+
unique='tre',
|
82
|
+
last='1970-01-01T00:06:00Z',
|
83
|
+
next='1970-01-01T00:07:00Z',
|
84
|
+
update='1970-01-01T01:00:00Z')
|
85
|
+
|
86
|
+
session.add(window)
|
87
|
+
|
88
|
+
session.commit()
|
89
|
+
|
87
90
|
|
88
91
|
windows.load_children()
|
89
92
|
|
@@ -105,12 +108,12 @@ def test_Windows(
|
|
105
108
|
|
106
109
|
assert attrs == [
|
107
110
|
'_Windows__params',
|
111
|
+
'_Windows__store',
|
112
|
+
'_Windows__group',
|
113
|
+
'_Windows__store_engine',
|
114
|
+
'_Windows__store_session',
|
108
115
|
'_Windows__start',
|
109
116
|
'_Windows__stop',
|
110
|
-
'_Windows__sqlite',
|
111
|
-
'_Windows__file',
|
112
|
-
'_Windows__table',
|
113
|
-
'_Windows__group',
|
114
117
|
'_Windows__windows']
|
115
118
|
|
116
119
|
|
@@ -127,19 +130,19 @@ def test_Windows(
|
|
127
130
|
|
128
131
|
assert windows.params is not None
|
129
132
|
|
130
|
-
assert windows.
|
131
|
-
'1970-01-01T00:05:10Z')
|
133
|
+
assert windows.store[:6] == 'sqlite'
|
132
134
|
|
133
|
-
assert windows.
|
134
|
-
'1970-01-01T00:10:10Z')
|
135
|
+
assert windows.group == 'default'
|
135
136
|
|
136
|
-
assert windows.
|
137
|
+
assert windows.store_engine is not None
|
137
138
|
|
138
|
-
assert windows.
|
139
|
+
assert windows.store_session is not None
|
139
140
|
|
140
|
-
assert windows.
|
141
|
+
assert windows.start == (
|
142
|
+
'1970-01-01T00:05:10Z')
|
141
143
|
|
142
|
-
assert windows.
|
144
|
+
assert windows.stop == (
|
145
|
+
'1970-01-01T00:10:10Z')
|
143
146
|
|
144
147
|
assert len(windows.children) == 2
|
145
148
|
|
@@ -173,37 +176,22 @@ def test_Windows_cover(
|
|
173
176
|
"""
|
174
177
|
|
175
178
|
|
176
|
-
assert windows.ready('one')
|
177
|
-
|
178
179
|
assert windows.ready('two')
|
179
180
|
|
180
|
-
|
181
181
|
windows.update('two', '+1h')
|
182
182
|
|
183
183
|
assert not windows.ready('two')
|
184
184
|
|
185
|
-
windows.load_children()
|
186
185
|
|
187
|
-
|
186
|
+
windows = Windows()
|
188
187
|
|
188
|
+
params = WindowParams(window=1)
|
189
189
|
|
190
|
-
windows.
|
191
|
-
|
192
|
-
assert not windows.ready('two')
|
193
|
-
|
194
|
-
windows.save_children()
|
195
|
-
windows.load_children()
|
196
|
-
|
197
|
-
assert not windows.ready('two')
|
198
|
-
|
190
|
+
windows.create('fur', params)
|
199
191
|
|
200
|
-
|
201
|
-
window='* * * * *',
|
202
|
-
start=310,
|
203
|
-
stop=610,
|
204
|
-
delay=10)
|
192
|
+
assert not windows.ready('fur')
|
205
193
|
|
206
|
-
|
194
|
+
sleep(2)
|
207
195
|
|
208
196
|
assert windows.ready('fur')
|
209
197
|
|