encommon 0.21.0__py3-none-any.whl → 0.22.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
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,55 @@
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
+ /*******************************************/
11
+ /* Standard structure for numeric elements */
12
+ /*******************************************/
13
+
14
+ div.encommon_numeric {
15
+ display: inline-block; }
16
+
17
+
18
+
19
+ /*******************************************/
20
+ /* Extended structure for numeric elements */
21
+ /*******************************************/
22
+
23
+ div.encommon_numeric
24
+ >._value {
25
+ font-family: monospace;
26
+ font-size: 1rem;
27
+ line-height: 1rem; }
28
+
29
+ div.encommon_numeric
30
+ >._delim {
31
+ font-size: .9rem;
32
+ line-height: .9rem;
33
+ opacity: .75; }
34
+
35
+ div.encommon_numeric
36
+ >._decimal {
37
+ font-family: monospace;
38
+ font-size: .9rem;
39
+ line-height: .9rem; }
40
+
41
+ div.encommon_numeric
42
+ >._unit {
43
+ font-size: .9rem;
44
+ line-height: .9rem;
45
+ opacity: .75; }
46
+
47
+
48
+
49
+ /********************************************/
50
+ /* Extended structure for datagrid elements */
51
+ /********************************************/
52
+
53
+ table.encommon_datagrid
54
+ >tbody>tr>td:has(.encommon_numeric) {
55
+ text-align: center; }
@@ -0,0 +1,50 @@
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
+ /*******************************************/
11
+ /* Standard structure for statate elements */
12
+ /*******************************************/
13
+
14
+ div.encommon_statate {
15
+ border-width: .1rem .1rem .1rem .1rem;
16
+ border-style: solid;
17
+ border-radius: .5rem .5rem .5rem .5rem;
18
+ padding: .1rem .2rem .1rem .2rem; }
19
+
20
+
21
+
22
+ /*******************************************/
23
+ /* Extended structure for statate elements */
24
+ /*******************************************/
25
+
26
+ .encommon_statate[data-status='failure'] {
27
+ background-color: rgba(var(--color-red-lite), .15);
28
+ border-color: rgba(var(--color-red-lite), .9); }
29
+
30
+ .encommon_statate[data-status='information'] {
31
+ background-color: rgba(var(--color-blue-lite), .15);
32
+ border-color: rgba(var(--color-blue-lite), .9); }
33
+
34
+ .encommon_statate[data-status='success'] {
35
+ background-color: rgba(var(--color-green-lite), .15);
36
+ border-color: rgba(var(--color-green-lite), .9); }
37
+
38
+ .encommon_statate[data-status='warning'] {
39
+ background-color: rgba(var(--color-yellow-lite), .15);
40
+ border-color: rgba(var(--color-yellow-lite), .9); }
41
+
42
+
43
+
44
+ /********************************************/
45
+ /* Extended structure for datagrid elements */
46
+ /********************************************/
47
+
48
+ table.encommon_datagrid
49
+ >tbody>tr>td:has(.encommon_statate) {
50
+ text-align: center; }
@@ -0,0 +1,45 @@
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
+ /******************************************/
11
+ /* Standard structure for tagues elements */
12
+ /******************************************/
13
+
14
+ div.encommon_tagues {
15
+ display: inline-block;
16
+ white-space: normal; }
17
+
18
+
19
+
20
+ /******************************************/
21
+ /* Extended structure for tagues elements */
22
+ /******************************************/
23
+
24
+ div.encommon_tagues
25
+ >._value {
26
+ background-color: rgba(var(--gritty), .2);
27
+ border-color: rgba(var(--pretty), .3);
28
+ border-radius: .2rem .2rem .2rem .2rem;
29
+ border-style: solid;
30
+ border-width: .1rem .1rem .1rem .1rem;
31
+ display: inline-block;
32
+ font-family: monospace;
33
+ font-size: .9rem;
34
+ margin: .1rem .1rem .1rem .1rem;
35
+ padding: .1rem .2rem .1rem .2rem; }
36
+
37
+
38
+
39
+ /********************************************/
40
+ /* Extended structure for datagrid elements */
41
+ /********************************************/
42
+
43
+ table.encommon_datagrid
44
+ >tbody>tr>td:has(.encommon_tagues) {
45
+ text-align: center; }
@@ -0,0 +1,39 @@
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 Any
11
+
12
+ from selenium.webdriver.remote.webdriver import WebDriver
13
+
14
+
15
+
16
+ def _executejs(
17
+ driver: WebDriver,
18
+ script: str,
19
+ *args: Any,
20
+ wrap: bool = True,
21
+ ) -> Any: # noqa: ANN401
22
+ """
23
+ Evaluate the provided JavaScript using the test driver.
24
+
25
+ :param driver: Selenium driver provided by the library.
26
+ :param script: Actual code that is executed with engine.
27
+ :param args: Positional arguments passed for downstream.
28
+ :param wrap: Determines if script is wrapped in return.
29
+ """
30
+
31
+ script = (
32
+ f'return {script};'
33
+ if wrap else script)
34
+
35
+ result = (
36
+ driver # type: ignore[no-untyped-call]
37
+ .execute_script(script, *args))
38
+
39
+ return result
@@ -0,0 +1,52 @@
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 Iterator
11
+
12
+ from pytest import fixture
13
+
14
+ from selenium import webdriver
15
+ from selenium.webdriver.chrome.options import Options
16
+ from selenium.webdriver.remote.webdriver import WebDriver
17
+
18
+ from ..content import Content
19
+
20
+
21
+
22
+ @fixture
23
+ def content() -> Content:
24
+ """
25
+ Construct the instance for use in the downstream tests.
26
+
27
+ :returns: Newly constructed instance of related class.
28
+ """
29
+
30
+ return Content()
31
+
32
+
33
+
34
+ @fixture
35
+ def driver() -> Iterator[WebDriver]:
36
+ """
37
+ Construct the instance for use in the downstream tests.
38
+
39
+ :returns: Newly constructed instance of related class.
40
+ """
41
+
42
+ options = Options()
43
+
44
+ options.add_argument('--headless')
45
+
46
+ driver = (
47
+ webdriver
48
+ .Chrome(options=options))
49
+
50
+ yield driver
51
+
52
+ driver.quit()
@@ -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_colordiv(
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('color')}
43
+ </script>
44
+ </head>
45
+ <body></body>
46
+ </html>
47
+ """)
48
+
49
+
50
+ outcome = _executejs(
51
+ driver,
52
+ 'let element ='
53
+ ' colordiv(...arguments);'
54
+ 'return'
55
+ ' element[0].outerHTML;',
56
+ '#FF00CC',
57
+ wrap=False)
58
+
59
+
60
+ assert outcome == (
61
+ '<div class="encommon_colordiv">'
62
+ '<div class="_value" style="'
63
+ 'background-color: rgb(255, 0, 204);'
64
+ '"></div></div>')
@@ -0,0 +1,98 @@
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 ...types import inrepr
13
+ from ...types import instr
14
+ from ...types import lattrs
15
+
16
+ if TYPE_CHECKING:
17
+ from ..content import Content
18
+
19
+
20
+
21
+ def test_Content(
22
+ content: 'Content',
23
+ ) -> None:
24
+ """
25
+ Perform various tests associated with relevant routines.
26
+
27
+ :param content: Primary class instance for the content.
28
+ """
29
+
30
+
31
+ attrs = lattrs(content)
32
+
33
+ assert attrs == []
34
+
35
+
36
+ assert inrepr(
37
+ 'content.Content',
38
+ content)
39
+
40
+ assert isinstance(
41
+ hash(content), int)
42
+
43
+ assert instr(
44
+ 'content.Content',
45
+ content)
46
+
47
+
48
+ script = (
49
+ content
50
+ .scripts('default'))
51
+
52
+ assert script is not None
53
+
54
+
55
+ styles = (
56
+ content
57
+ .styles('default'))
58
+
59
+ assert styles is not None
60
+
61
+
62
+ image = (
63
+ content
64
+ .images('enasis'))
65
+
66
+ assert image is not None
67
+
68
+
69
+
70
+ def test_Content_cover(
71
+ content: 'Content',
72
+ ) -> None:
73
+ """
74
+ Perform various tests associated with relevant routines.
75
+
76
+ :param content: Primary class instance for the content.
77
+ """
78
+
79
+
80
+ script = (
81
+ content
82
+ .scripts('doesnotexist'))
83
+
84
+ assert script is None
85
+
86
+
87
+ styles = (
88
+ content
89
+ .styles('doesnotexist'))
90
+
91
+ assert styles is None
92
+
93
+
94
+ image = (
95
+ content
96
+ .images('doesnotexist'))
97
+
98
+ assert image is None
@@ -0,0 +1,90 @@
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_datagrid(
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('datagrid')}
43
+ </script>
44
+ </head>
45
+ <body></body>
46
+ </html>
47
+ """)
48
+
49
+
50
+ fields = {
51
+ 'foo': 'Foo',
52
+ 'bar': 'Bar'}
53
+
54
+ values = [
55
+ {'foo': '1',
56
+ 'bar': 1},
57
+ {'foo': '2',
58
+ 'bar': 2}]
59
+
60
+
61
+ outcome = _executejs(
62
+ driver,
63
+ 'let element ='
64
+ ' datagrid(...arguments);'
65
+ 'return'
66
+ ' element[0].outerHTML;',
67
+ fields,
68
+ values,
69
+ wrap=False)
70
+
71
+
72
+ assert outcome == (
73
+ '<table class="encommon_datagrid">'
74
+ '<thead>'
75
+ '<tr>'
76
+ '<th>Bar</th>'
77
+ '<th>Foo</th>'
78
+ '</tr>'
79
+ '</thead>'
80
+ '<tbody>'
81
+ '<tr>'
82
+ '<td>1</td>'
83
+ '<td>1</td>'
84
+ '</tr>'
85
+ '<tr>'
86
+ '<td>2</td>'
87
+ '<td>2</td>'
88
+ '</tr>'
89
+ '</tbody>'
90
+ '</table>')
@@ -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_datestamp(
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('datetime')}
43
+ </script>
44
+ </head>
45
+ <body></body>
46
+ </html>
47
+ """)
48
+
49
+
50
+ outcome = _executejs(
51
+ driver,
52
+ 'let element ='
53
+ ' datestamp(...arguments);'
54
+ 'return'
55
+ ' element[0].outerHTML;',
56
+ '2024-04-20T16:20:00Z',
57
+ wrap=False)
58
+
59
+
60
+ assert outcome == (
61
+ '<div class="encommon_datestamp">'
62
+ '<span class="_value _year">2024</span>'
63
+ '<span class="_delim _slash">-</span>'
64
+ '<span class="_value _month">04</span>'
65
+ '<span class="_delim _slash">-</span>'
66
+ '<span class="_value _day">20</span>'
67
+ '<span class="_delim _space">&nbsp;</span>'
68
+ '<span class="_value _hours">16</span>'
69
+ '<span class="_delim _colon">:</span>'
70
+ '<span class="_value _minutes">20</span>'
71
+ '<span class="_delim _colon">:</span>'
72
+ '<span class="_value _seconds">00</span>'
73
+ '<span class="_delim _space">&nbsp;</span>'
74
+ '<span class="_tzname">UTC</span>'
75
+ '</div>')