encommon 0.21.0__py3-none-any.whl → 0.22.1__py3-none-any.whl
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/times/common.py +3 -0
- encommon/times/unitime.py +23 -11
- encommon/version.txt +1 -1
- encommon/webkit/__init__.py +15 -0
- encommon/webkit/content.py +94 -0
- encommon/webkit/images/enasis.svg +174 -0
- encommon/webkit/images/failure.svg +15 -0
- encommon/webkit/images/information.svg +18 -0
- encommon/webkit/images/success.svg +18 -0
- encommon/webkit/images/warning.svg +16 -0
- encommon/webkit/index.html +218 -0
- encommon/webkit/scripts/color.js +60 -0
- encommon/webkit/scripts/datagrid.js +105 -0
- encommon/webkit/scripts/datetime.js +160 -0
- encommon/webkit/scripts/default.js +327 -0
- encommon/webkit/scripts/duration.js +150 -0
- encommon/webkit/scripts/helpers.js +247 -0
- encommon/webkit/scripts/image.js +39 -0
- encommon/webkit/scripts/message.js +31 -0
- encommon/webkit/scripts/moderate.js +71 -0
- encommon/webkit/scripts/numeric.js +189 -0
- encommon/webkit/scripts/statate.js +35 -0
- encommon/webkit/scripts/tagues.js +34 -0
- encommon/webkit/styles/color.css +57 -0
- encommon/webkit/styles/datagrid.css +58 -0
- encommon/webkit/styles/datetime.css +50 -0
- encommon/webkit/styles/default.css +204 -0
- encommon/webkit/styles/duration.css +44 -0
- encommon/webkit/styles/image.css +60 -0
- encommon/webkit/styles/message.css +88 -0
- encommon/webkit/styles/moderate.css +64 -0
- encommon/webkit/styles/numeric.css +55 -0
- encommon/webkit/styles/statate.css +50 -0
- encommon/webkit/styles/tagues.css +45 -0
- encommon/webkit/test/__init__.py +39 -0
- encommon/webkit/test/conftest.py +52 -0
- encommon/webkit/test/test_color.py +64 -0
- encommon/webkit/test/test_content.py +98 -0
- encommon/webkit/test/test_datagrid.py +90 -0
- encommon/webkit/test/test_datetime.py +75 -0
- encommon/webkit/test/test_default.py +314 -0
- encommon/webkit/test/test_duration.py +74 -0
- encommon/webkit/test/test_helpers.py +382 -0
- encommon/webkit/test/test_image.py +62 -0
- encommon/webkit/test/test_message.py +64 -0
- encommon/webkit/test/test_moderate.py +75 -0
- encommon/webkit/test/test_numeric.py +164 -0
- encommon/webkit/test/test_statate.py +78 -0
- encommon/webkit/test/test_tagues.py +66 -0
- {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/METADATA +1 -1
- {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/RECORD +54 -8
- {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/LICENSE +0 -0
- {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/WHEEL +0 -0
- {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,382 @@
|
|
1
|
+
"""
|
2
|
+
Functions and routines associated with Enasis Network Common Library.
|
3
|
+
|
4
|
+
This file is part of Enasis Network software eco-system. Distribution
|
5
|
+
is permitted, for more information consult the project license file.
|
6
|
+
"""
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
from typing import TYPE_CHECKING
|
11
|
+
|
12
|
+
from pytest import fixture
|
13
|
+
|
14
|
+
from selenium.webdriver.remote.webdriver import WebDriver
|
15
|
+
|
16
|
+
from . import _executejs
|
17
|
+
|
18
|
+
if TYPE_CHECKING:
|
19
|
+
from ..content import Content
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
@fixture
|
24
|
+
def prepare(
|
25
|
+
content: 'Content',
|
26
|
+
driver: WebDriver,
|
27
|
+
) -> tuple['Content', WebDriver]:
|
28
|
+
"""
|
29
|
+
Construct the instance for use in the downstream tests.
|
30
|
+
|
31
|
+
:returns: Newly constructed instance of related class.
|
32
|
+
"""
|
33
|
+
|
34
|
+
driver.get(
|
35
|
+
f"""
|
36
|
+
data:text/html;
|
37
|
+
charset=utf-8,
|
38
|
+
<html>
|
39
|
+
<head>
|
40
|
+
<script>
|
41
|
+
{content.scripts('default')}
|
42
|
+
{content.scripts('helpers')}
|
43
|
+
</script>
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
<div>Hello</div>
|
47
|
+
<span>World</span>
|
48
|
+
</body>
|
49
|
+
</html>
|
50
|
+
""")
|
51
|
+
|
52
|
+
return (content, driver)
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
def test_helpers_assert(
|
57
|
+
prepare: tuple['Content', WebDriver],
|
58
|
+
) -> None:
|
59
|
+
"""
|
60
|
+
Perform various tests associated with relevant routines.
|
61
|
+
|
62
|
+
:param prepare: Driver and content loaded with scripts.
|
63
|
+
"""
|
64
|
+
|
65
|
+
content, driver = prepare
|
66
|
+
|
67
|
+
outcome = _executejs(
|
68
|
+
driver,
|
69
|
+
'assert(1 == 1)')
|
70
|
+
|
71
|
+
assert outcome is True
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
def test_helpers_whenready(
|
76
|
+
prepare: tuple['Content', WebDriver],
|
77
|
+
) -> None:
|
78
|
+
"""
|
79
|
+
Perform various tests associated with relevant routines.
|
80
|
+
|
81
|
+
:param prepare: Driver and content loaded with scripts.
|
82
|
+
"""
|
83
|
+
|
84
|
+
content, driver = prepare
|
85
|
+
|
86
|
+
_executejs(
|
87
|
+
driver,
|
88
|
+
'whenready('
|
89
|
+
'console.log)')
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
def test_helpers_isnull(
|
94
|
+
prepare: tuple['Content', WebDriver],
|
95
|
+
) -> None:
|
96
|
+
"""
|
97
|
+
Perform various tests associated with relevant routines.
|
98
|
+
|
99
|
+
:param prepare: Driver and content loaded with scripts.
|
100
|
+
"""
|
101
|
+
|
102
|
+
content, driver = prepare
|
103
|
+
|
104
|
+
outcome = _executejs(
|
105
|
+
driver,
|
106
|
+
'isnull(undefined)'
|
107
|
+
' && isnull(null)')
|
108
|
+
|
109
|
+
assert outcome is True
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
def test_helpers_isempty(
|
114
|
+
prepare: tuple['Content', WebDriver],
|
115
|
+
) -> None:
|
116
|
+
"""
|
117
|
+
Perform various tests associated with relevant routines.
|
118
|
+
|
119
|
+
:param prepare: Driver and content loaded with scripts.
|
120
|
+
"""
|
121
|
+
|
122
|
+
content, driver = prepare
|
123
|
+
|
124
|
+
outcome = _executejs(
|
125
|
+
driver,
|
126
|
+
'isempty({})'
|
127
|
+
' && isempty("")'
|
128
|
+
' && isempty([])')
|
129
|
+
|
130
|
+
assert outcome is True
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
def test_helpers_isbool(
|
135
|
+
prepare: tuple['Content', WebDriver],
|
136
|
+
) -> None:
|
137
|
+
"""
|
138
|
+
Perform various tests associated with relevant routines.
|
139
|
+
|
140
|
+
:param prepare: Driver and content loaded with scripts.
|
141
|
+
"""
|
142
|
+
|
143
|
+
content, driver = prepare
|
144
|
+
|
145
|
+
outcome = _executejs(
|
146
|
+
driver,
|
147
|
+
'isbool(true)')
|
148
|
+
|
149
|
+
assert outcome is True
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
def test_helpers_isstr(
|
154
|
+
prepare: tuple['Content', WebDriver],
|
155
|
+
) -> None:
|
156
|
+
"""
|
157
|
+
Perform various tests associated with relevant routines.
|
158
|
+
|
159
|
+
:param prepare: Driver and content loaded with scripts.
|
160
|
+
"""
|
161
|
+
|
162
|
+
content, driver = prepare
|
163
|
+
|
164
|
+
outcome = _executejs(
|
165
|
+
driver,
|
166
|
+
'isstr("string")')
|
167
|
+
|
168
|
+
assert outcome is True
|
169
|
+
|
170
|
+
outcome = _executejs(
|
171
|
+
driver,
|
172
|
+
'isstr(69429)')
|
173
|
+
|
174
|
+
assert outcome is False
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
def test_helpers_isnum(
|
179
|
+
prepare: tuple['Content', WebDriver],
|
180
|
+
) -> None:
|
181
|
+
"""
|
182
|
+
Perform various tests associated with relevant routines.
|
183
|
+
|
184
|
+
:param prepare: Driver and content loaded with scripts.
|
185
|
+
"""
|
186
|
+
|
187
|
+
content, driver = prepare
|
188
|
+
|
189
|
+
outcome = _executejs(
|
190
|
+
driver,
|
191
|
+
'isnum(123)')
|
192
|
+
|
193
|
+
assert outcome is True
|
194
|
+
|
195
|
+
outcome = _executejs(
|
196
|
+
driver,
|
197
|
+
'isnum(1.23)')
|
198
|
+
|
199
|
+
assert outcome is True
|
200
|
+
|
201
|
+
outcome = _executejs(
|
202
|
+
driver,
|
203
|
+
'isnum("69429")')
|
204
|
+
|
205
|
+
assert outcome is False
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
def test_helpers_isquery(
|
210
|
+
prepare: tuple['Content', WebDriver],
|
211
|
+
) -> None:
|
212
|
+
"""
|
213
|
+
Perform various tests associated with relevant routines.
|
214
|
+
|
215
|
+
:param prepare: Driver and content loaded with scripts.
|
216
|
+
"""
|
217
|
+
|
218
|
+
content, driver = prepare
|
219
|
+
|
220
|
+
outcome = _executejs(
|
221
|
+
driver,
|
222
|
+
('let element = $("<p/>");'
|
223
|
+
'return isquery(element);'),
|
224
|
+
wrap=False)
|
225
|
+
|
226
|
+
assert outcome is True
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
def test_helpers_isnode(
|
231
|
+
prepare: tuple['Content', WebDriver],
|
232
|
+
) -> None:
|
233
|
+
"""
|
234
|
+
Perform various tests associated with relevant routines.
|
235
|
+
|
236
|
+
:param prepare: Driver and content loaded with scripts.
|
237
|
+
"""
|
238
|
+
|
239
|
+
content, driver = prepare
|
240
|
+
|
241
|
+
outcome = _executejs(
|
242
|
+
driver,
|
243
|
+
('let element = $("<p/>");'
|
244
|
+
'return isnode(element[0]);'),
|
245
|
+
wrap=False)
|
246
|
+
|
247
|
+
assert outcome is True
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
def test_helpers_istime(
|
252
|
+
prepare: tuple['Content', WebDriver],
|
253
|
+
) -> None:
|
254
|
+
"""
|
255
|
+
Perform various tests associated with relevant routines.
|
256
|
+
|
257
|
+
:param prepare: Driver and content loaded with scripts.
|
258
|
+
"""
|
259
|
+
|
260
|
+
content, driver = prepare
|
261
|
+
|
262
|
+
outcome = _executejs(
|
263
|
+
driver,
|
264
|
+
'istime("2024-04-20")')
|
265
|
+
|
266
|
+
assert outcome is True
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
def test_helpers_islist(
|
271
|
+
prepare: tuple['Content', WebDriver],
|
272
|
+
) -> None:
|
273
|
+
"""
|
274
|
+
Perform various tests associated with relevant routines.
|
275
|
+
|
276
|
+
:param prepare: Driver and content loaded with scripts.
|
277
|
+
"""
|
278
|
+
|
279
|
+
content, driver = prepare
|
280
|
+
|
281
|
+
outcome = _executejs(
|
282
|
+
driver,
|
283
|
+
'islist([69429])')
|
284
|
+
|
285
|
+
assert outcome is True
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
def test_helpers_isdict(
|
290
|
+
prepare: tuple['Content', WebDriver],
|
291
|
+
) -> None:
|
292
|
+
"""
|
293
|
+
Perform various tests associated with relevant routines.
|
294
|
+
|
295
|
+
:param prepare: Driver and content loaded with scripts.
|
296
|
+
"""
|
297
|
+
|
298
|
+
content, driver = prepare
|
299
|
+
|
300
|
+
outcome = _executejs(
|
301
|
+
driver,
|
302
|
+
'isdict({"foo": "bar"})')
|
303
|
+
|
304
|
+
assert outcome is True
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
def test_helpers_istrue(
|
309
|
+
prepare: tuple['Content', WebDriver],
|
310
|
+
) -> None:
|
311
|
+
"""
|
312
|
+
Perform various tests associated with relevant routines.
|
313
|
+
|
314
|
+
:param prepare: Driver and content loaded with scripts.
|
315
|
+
"""
|
316
|
+
|
317
|
+
content, driver = prepare
|
318
|
+
|
319
|
+
outcome = _executejs(
|
320
|
+
driver,
|
321
|
+
'istrue(true)')
|
322
|
+
|
323
|
+
assert outcome is True
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
def test_helpers_isfalse(
|
328
|
+
prepare: tuple['Content', WebDriver],
|
329
|
+
) -> None:
|
330
|
+
"""
|
331
|
+
Perform various tests associated with relevant routines.
|
332
|
+
|
333
|
+
:param prepare: Driver and content loaded with scripts.
|
334
|
+
"""
|
335
|
+
|
336
|
+
content, driver = prepare
|
337
|
+
|
338
|
+
outcome = _executejs(
|
339
|
+
driver,
|
340
|
+
'isfalse(false)')
|
341
|
+
|
342
|
+
assert outcome is True
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
def test_helpers_loads(
|
347
|
+
prepare: tuple['Content', WebDriver],
|
348
|
+
) -> None:
|
349
|
+
"""
|
350
|
+
Perform various tests associated with relevant routines.
|
351
|
+
|
352
|
+
:param prepare: Driver and content loaded with scripts.
|
353
|
+
"""
|
354
|
+
|
355
|
+
content, driver = prepare
|
356
|
+
|
357
|
+
outcome = _executejs(
|
358
|
+
driver,
|
359
|
+
'loads(\'{"foo":"bar"}\')')
|
360
|
+
|
361
|
+
assert outcome['foo'] == 'bar'
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
def test_helpers_dumps(
|
366
|
+
prepare: tuple['Content', WebDriver],
|
367
|
+
) -> None:
|
368
|
+
"""
|
369
|
+
Perform various tests associated with relevant routines.
|
370
|
+
|
371
|
+
:param prepare: Driver and content loaded with scripts.
|
372
|
+
"""
|
373
|
+
|
374
|
+
content, driver = prepare
|
375
|
+
|
376
|
+
dumped = '{"foo":"bar"}'
|
377
|
+
|
378
|
+
outcome = _executejs(
|
379
|
+
driver,
|
380
|
+
'dumps({"foo": "bar"})')
|
381
|
+
|
382
|
+
assert outcome == dumped
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"""
|
2
|
+
Functions and routines associated with Enasis Network Common Library.
|
3
|
+
|
4
|
+
This file is part of Enasis Network software eco-system. Distribution
|
5
|
+
is permitted, for more information consult the project license file.
|
6
|
+
"""
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
from typing import TYPE_CHECKING
|
11
|
+
|
12
|
+
from selenium.webdriver.remote.webdriver import WebDriver
|
13
|
+
|
14
|
+
from . import _executejs
|
15
|
+
|
16
|
+
if TYPE_CHECKING:
|
17
|
+
from ..content import Content
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
def test_image(
|
22
|
+
content: 'Content',
|
23
|
+
driver: WebDriver,
|
24
|
+
) -> None:
|
25
|
+
"""
|
26
|
+
Perform various tests associated with relevant routines.
|
27
|
+
|
28
|
+
:param content: Primary class instance for the content.
|
29
|
+
:param driver: Selenium driver provided by the library.
|
30
|
+
"""
|
31
|
+
|
32
|
+
|
33
|
+
driver.get(
|
34
|
+
f"""
|
35
|
+
data:text/html;
|
36
|
+
charset=utf-8,
|
37
|
+
<html>
|
38
|
+
<head>
|
39
|
+
<script>
|
40
|
+
{content.scripts('default')}
|
41
|
+
{content.scripts('helpers')}
|
42
|
+
{content.scripts('image')}
|
43
|
+
</script>
|
44
|
+
</head>
|
45
|
+
<body></body>
|
46
|
+
</html>
|
47
|
+
""")
|
48
|
+
|
49
|
+
|
50
|
+
outcome = _executejs(
|
51
|
+
driver,
|
52
|
+
'let element ='
|
53
|
+
' svgicon(...arguments);'
|
54
|
+
'return'
|
55
|
+
' element[0].outerHTML;',
|
56
|
+
'failure',
|
57
|
+
wrap=False)
|
58
|
+
|
59
|
+
|
60
|
+
assert outcome == (
|
61
|
+
'<div class="encommon_svgicon"'
|
62
|
+
' data-image="failure"></div>')
|
@@ -0,0 +1,64 @@
|
|
1
|
+
"""
|
2
|
+
Functions and routines associated with Enasis Network Common Library.
|
3
|
+
|
4
|
+
This file is part of Enasis Network software eco-system. Distribution
|
5
|
+
is permitted, for more information consult the project license file.
|
6
|
+
"""
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
from typing import TYPE_CHECKING
|
11
|
+
|
12
|
+
from selenium.webdriver.remote.webdriver import WebDriver
|
13
|
+
|
14
|
+
from . import _executejs
|
15
|
+
|
16
|
+
if TYPE_CHECKING:
|
17
|
+
from ..content import Content
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
def test_message(
|
22
|
+
content: 'Content',
|
23
|
+
driver: WebDriver,
|
24
|
+
) -> None:
|
25
|
+
"""
|
26
|
+
Perform various tests associated with relevant routines.
|
27
|
+
|
28
|
+
:param content: Primary class instance for the content.
|
29
|
+
:param driver: Selenium driver provided by the library.
|
30
|
+
"""
|
31
|
+
|
32
|
+
|
33
|
+
driver.get(
|
34
|
+
f"""
|
35
|
+
data:text/html;
|
36
|
+
charset=utf-8,
|
37
|
+
<html>
|
38
|
+
<head>
|
39
|
+
<script>
|
40
|
+
{content.scripts('default')}
|
41
|
+
{content.scripts('helpers')}
|
42
|
+
{content.scripts('message')}
|
43
|
+
</script>
|
44
|
+
</head>
|
45
|
+
<body></body>
|
46
|
+
</html>
|
47
|
+
""")
|
48
|
+
|
49
|
+
|
50
|
+
outcome = _executejs(
|
51
|
+
driver,
|
52
|
+
'let element ='
|
53
|
+
' message(...arguments);'
|
54
|
+
'return'
|
55
|
+
' element[0].outerHTML;',
|
56
|
+
'information',
|
57
|
+
'This is the message',
|
58
|
+
wrap=False)
|
59
|
+
|
60
|
+
|
61
|
+
assert outcome == (
|
62
|
+
'<div class="encommon_message"'
|
63
|
+
' data-level="information">'
|
64
|
+
'This is the message</div>')
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"""
|
2
|
+
Functions and routines associated with Enasis Network Common Library.
|
3
|
+
|
4
|
+
This file is part of Enasis Network software eco-system. Distribution
|
5
|
+
is permitted, for more information consult the project license file.
|
6
|
+
"""
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
from typing import TYPE_CHECKING
|
11
|
+
|
12
|
+
from selenium.webdriver.remote.webdriver import WebDriver
|
13
|
+
|
14
|
+
from . import _executejs
|
15
|
+
|
16
|
+
if TYPE_CHECKING:
|
17
|
+
from ..content import Content
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
def test_moderate(
|
22
|
+
content: 'Content',
|
23
|
+
driver: WebDriver,
|
24
|
+
) -> None:
|
25
|
+
"""
|
26
|
+
Perform various tests associated with relevant routines.
|
27
|
+
|
28
|
+
:param content: Primary class instance for the content.
|
29
|
+
:param driver: Selenium driver provided by the library.
|
30
|
+
"""
|
31
|
+
|
32
|
+
|
33
|
+
driver.get(
|
34
|
+
f"""
|
35
|
+
data:text/html;
|
36
|
+
charset=utf-8,
|
37
|
+
<html>
|
38
|
+
<head>
|
39
|
+
<script>
|
40
|
+
{content.scripts('default')}
|
41
|
+
{content.scripts('helpers')}
|
42
|
+
{content.scripts('image')}
|
43
|
+
{content.scripts('moderate')}
|
44
|
+
</script>
|
45
|
+
</head>
|
46
|
+
<body></body>
|
47
|
+
</html>
|
48
|
+
""")
|
49
|
+
|
50
|
+
|
51
|
+
outcome = _executejs(
|
52
|
+
driver,
|
53
|
+
'let element ='
|
54
|
+
' moderate(...arguments);'
|
55
|
+
'return'
|
56
|
+
' element[0].outerHTML;',
|
57
|
+
'This is a Label',
|
58
|
+
'success',
|
59
|
+
'some_kind_short',
|
60
|
+
wrap=False)
|
61
|
+
|
62
|
+
|
63
|
+
assert outcome == (
|
64
|
+
'<div class="encommon_moderate">'
|
65
|
+
'<div class="_icon">'
|
66
|
+
'<div class="encommon_svgicon"'
|
67
|
+
' data-image="success"></div>'
|
68
|
+
'</div>'
|
69
|
+
'<div class="_value">'
|
70
|
+
'<div class="_label">'
|
71
|
+
'This is a Label</div>'
|
72
|
+
'<div class="_small">'
|
73
|
+
'some_kind_short</div>'
|
74
|
+
'</div>'
|
75
|
+
'</div>')
|