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.
Files changed (54) hide show
  1. encommon/times/common.py +3 -0
  2. encommon/times/unitime.py +23 -11
  3. encommon/version.txt +1 -1
  4. encommon/webkit/__init__.py +15 -0
  5. encommon/webkit/content.py +94 -0
  6. encommon/webkit/images/enasis.svg +174 -0
  7. encommon/webkit/images/failure.svg +15 -0
  8. encommon/webkit/images/information.svg +18 -0
  9. encommon/webkit/images/success.svg +18 -0
  10. encommon/webkit/images/warning.svg +16 -0
  11. encommon/webkit/index.html +218 -0
  12. encommon/webkit/scripts/color.js +60 -0
  13. encommon/webkit/scripts/datagrid.js +105 -0
  14. encommon/webkit/scripts/datetime.js +160 -0
  15. encommon/webkit/scripts/default.js +327 -0
  16. encommon/webkit/scripts/duration.js +150 -0
  17. encommon/webkit/scripts/helpers.js +247 -0
  18. encommon/webkit/scripts/image.js +39 -0
  19. encommon/webkit/scripts/message.js +31 -0
  20. encommon/webkit/scripts/moderate.js +71 -0
  21. encommon/webkit/scripts/numeric.js +189 -0
  22. encommon/webkit/scripts/statate.js +35 -0
  23. encommon/webkit/scripts/tagues.js +34 -0
  24. encommon/webkit/styles/color.css +57 -0
  25. encommon/webkit/styles/datagrid.css +58 -0
  26. encommon/webkit/styles/datetime.css +50 -0
  27. encommon/webkit/styles/default.css +204 -0
  28. encommon/webkit/styles/duration.css +44 -0
  29. encommon/webkit/styles/image.css +60 -0
  30. encommon/webkit/styles/message.css +88 -0
  31. encommon/webkit/styles/moderate.css +64 -0
  32. encommon/webkit/styles/numeric.css +55 -0
  33. encommon/webkit/styles/statate.css +50 -0
  34. encommon/webkit/styles/tagues.css +45 -0
  35. encommon/webkit/test/__init__.py +39 -0
  36. encommon/webkit/test/conftest.py +52 -0
  37. encommon/webkit/test/test_color.py +64 -0
  38. encommon/webkit/test/test_content.py +98 -0
  39. encommon/webkit/test/test_datagrid.py +90 -0
  40. encommon/webkit/test/test_datetime.py +75 -0
  41. encommon/webkit/test/test_default.py +314 -0
  42. encommon/webkit/test/test_duration.py +74 -0
  43. encommon/webkit/test/test_helpers.py +382 -0
  44. encommon/webkit/test/test_image.py +62 -0
  45. encommon/webkit/test/test_message.py +64 -0
  46. encommon/webkit/test/test_moderate.py +75 -0
  47. encommon/webkit/test/test_numeric.py +164 -0
  48. encommon/webkit/test/test_statate.py +78 -0
  49. encommon/webkit/test/test_tagues.py +66 -0
  50. {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/METADATA +1 -1
  51. {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/RECORD +54 -8
  52. {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/LICENSE +0 -0
  53. {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/WHEEL +0 -0
  54. {encommon-0.21.0.dist-info → encommon-0.22.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,314 @@
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
+ from ...types.strings import SEMPTY
18
+
19
+ if TYPE_CHECKING:
20
+ from ..content import Content
21
+
22
+
23
+
24
+ @fixture
25
+ def prepare(
26
+ content: 'Content',
27
+ driver: WebDriver,
28
+ ) -> tuple['Content', WebDriver]:
29
+ """
30
+ Construct the instance for use in the downstream tests.
31
+
32
+ :returns: Newly constructed instance of related class.
33
+ """
34
+
35
+ driver.get(
36
+ f"""
37
+ data:text/html;
38
+ charset=utf-8,
39
+ <html>
40
+ <head>
41
+ <script>
42
+ {content.scripts('default')}
43
+ {content.scripts('helpers')}
44
+ </script>
45
+ </head>
46
+ <body>
47
+ <div>Hello</div>
48
+ <span>World</span>
49
+ </body>
50
+ </html>
51
+ """)
52
+
53
+ return (content, driver)
54
+
55
+
56
+
57
+ def test_default_create(
58
+ prepare: tuple['Content', WebDriver],
59
+ ) -> None:
60
+ """
61
+ Perform various tests associated with relevant routines.
62
+
63
+ :param prepare: Driver and content loaded with scripts.
64
+ """
65
+
66
+ content, driver = prepare
67
+
68
+ outcome = _executejs(
69
+ driver,
70
+ '$("<p/>")[0]'
71
+ '.tagName;')
72
+
73
+ assert outcome == 'P'
74
+
75
+
76
+
77
+ def test_default_styles(
78
+ prepare: tuple['Content', WebDriver],
79
+ ) -> None:
80
+ """
81
+ Perform various tests associated with relevant routines.
82
+
83
+ :param prepare: Driver and content loaded with scripts.
84
+ """
85
+
86
+ content, driver = prepare
87
+
88
+ _executejs(
89
+ driver,
90
+ '$("body>div")'
91
+ '.css("color", "blue")'
92
+ '.css("color", "red");',
93
+ wrap=False)
94
+
95
+ outcome = _executejs(
96
+ driver,
97
+ '$("body>div")[0]'
98
+ '.style.color;')
99
+
100
+ assert outcome == 'red'
101
+
102
+
103
+
104
+ def test_default_addClass(
105
+ prepare: tuple['Content', WebDriver],
106
+ ) -> None:
107
+ """
108
+ Perform various tests associated with relevant routines.
109
+
110
+ :param prepare: Driver and content loaded with scripts.
111
+ """
112
+
113
+ content, driver = prepare
114
+
115
+ _executejs(
116
+ driver,
117
+ '$("body>div")'
118
+ '.addClass("pytest")')
119
+
120
+ outcome = _executejs(
121
+ driver,
122
+ '$("body>div")[0]'
123
+ '.classList;')
124
+
125
+ assert len(outcome) == 1
126
+
127
+
128
+
129
+ def test_default_remClass(
130
+ prepare: tuple['Content', WebDriver],
131
+ ) -> None:
132
+ """
133
+ Perform various tests associated with relevant routines.
134
+
135
+ :param prepare: Driver and content loaded with scripts.
136
+ """
137
+
138
+ content, driver = prepare
139
+
140
+ _executejs(
141
+ driver,
142
+ '$("body>div")'
143
+ '.remClass("pytest")')
144
+
145
+ outcome = _executejs(
146
+ driver,
147
+ '$("body>div")[0]'
148
+ '.classList;')
149
+
150
+ assert len(outcome) == 0
151
+
152
+
153
+
154
+ def test_default_showhide(
155
+ prepare: tuple['Content', WebDriver],
156
+ ) -> None:
157
+ """
158
+ Perform various tests associated with relevant routines.
159
+
160
+ :param prepare: Driver and content loaded with scripts.
161
+ """
162
+
163
+ content, driver = prepare
164
+
165
+ outcome = _executejs(
166
+ driver,
167
+ '$("body>div")[0]'
168
+ '.style.display;')
169
+
170
+ assert outcome == SEMPTY
171
+
172
+ _executejs(
173
+ driver,
174
+ '$("body>div").hide();',
175
+ wrap=False)
176
+
177
+ outcome = _executejs(
178
+ driver,
179
+ '$("body>div")[0]'
180
+ '.style.display;')
181
+
182
+ assert outcome == 'none'
183
+
184
+ _executejs(
185
+ driver,
186
+ '$("body>div")'
187
+ '.hide().show();',
188
+ wrap=False)
189
+
190
+ outcome = _executejs(
191
+ driver,
192
+ '$("body>div")[0]'
193
+ '.style.display;')
194
+
195
+ assert outcome == 'block'
196
+
197
+
198
+
199
+ def test_default_content(
200
+ prepare: tuple['Content', WebDriver],
201
+ ) -> None:
202
+ """
203
+ Perform various tests associated with relevant routines.
204
+
205
+ :param prepare: Driver and content loaded with scripts.
206
+ """
207
+
208
+ content, driver = prepare
209
+
210
+
211
+ _executejs(
212
+ driver,
213
+ '$("body>div")'
214
+ '.html("<p>pytest</p>");')
215
+
216
+ outcome = _executejs(
217
+ driver,
218
+ '$("body>div").text();')
219
+
220
+ assert outcome == 'pytest'
221
+
222
+
223
+ _executejs(
224
+ driver,
225
+ '$("body>span")'
226
+ '.text("pytest");')
227
+
228
+ outcome = _executejs(
229
+ driver,
230
+ '$("body>span").text();')
231
+
232
+ assert outcome == 'pytest'
233
+
234
+
235
+
236
+ def test_default_append(
237
+ prepare: tuple['Content', WebDriver],
238
+ ) -> None:
239
+ """
240
+ Perform various tests associated with relevant routines.
241
+
242
+ :param prepare: Driver and content loaded with scripts.
243
+ """
244
+
245
+ content, driver = prepare
246
+
247
+ _executejs(
248
+ driver,
249
+ 'let element = $("<p/>");'
250
+ 'let target = $("body");'
251
+ 'element.text("pytest");'
252
+ 'target.append(element);',
253
+ wrap=False)
254
+
255
+ outcome = _executejs(
256
+ driver,
257
+ '$("body>p")[0]'
258
+ '.textContent;')
259
+
260
+ assert outcome == 'pytest'
261
+
262
+
263
+
264
+ def test_default_replace(
265
+ prepare: tuple['Content', WebDriver],
266
+ ) -> None:
267
+ """
268
+ Perform various tests associated with relevant routines.
269
+
270
+ :param prepare: Driver and content loaded with scripts.
271
+ """
272
+
273
+ content, driver = prepare
274
+
275
+ _executejs(
276
+ driver,
277
+ 'let element = $("<p/>");'
278
+ 'let target = $("body");'
279
+ 'element.text("pytest");'
280
+ 'target.replace(element);',
281
+ wrap=False)
282
+
283
+ outcome = _executejs(
284
+ driver,
285
+ '$("body>p")[0]'
286
+ '.textContent;')
287
+
288
+ assert outcome == 'pytest'
289
+
290
+
291
+
292
+ def test_default_attr(
293
+ prepare: tuple['Content', WebDriver],
294
+ ) -> None:
295
+ """
296
+ Perform various tests associated with relevant routines.
297
+
298
+ :param prepare: Driver and content loaded with scripts.
299
+ """
300
+
301
+ content, driver = prepare
302
+
303
+ _executejs(
304
+ driver,
305
+ '$("body")'
306
+ '.attr("foo", "bar")')
307
+
308
+ outcome = _executejs(
309
+ driver,
310
+ 'return $("body")'
311
+ ' .attr("foo");',
312
+ wrap=False)
313
+
314
+ assert outcome == 'bar'
@@ -0,0 +1,74 @@
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_duration(
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('duration')}
43
+ </script>
44
+ </head>
45
+ <body></body>
46
+ </html>
47
+ """)
48
+
49
+
50
+ outcome = _executejs(
51
+ driver,
52
+ 'let element ='
53
+ ' duration(...arguments);'
54
+ 'return'
55
+ ' element[0].outerHTML;',
56
+ 90460023,
57
+ wrap=False)
58
+
59
+
60
+ assert outcome == (
61
+ '<div class="encommon_duration">'
62
+ '<span class="_value">2</span>'
63
+ '<span class="_unit">y</span>'
64
+ '<span class="_value">10</span>'
65
+ '<span class="_unit">mon</span>'
66
+ '<span class="_value">2</span>'
67
+ '<span class="_unit">w</span>'
68
+ '<span class="_value">2</span>'
69
+ '<span class="_unit">d</span>'
70
+ '<span class="_value">23</span>'
71
+ '<span class="_unit">h</span>'
72
+ '<span class="_value">47</span>'
73
+ '<span class="_unit">m</span>'
74
+ '</div>')