orionis 0.431.0__py3-none-any.whl → 0.434.0__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.
- orionis/app.py +17 -0
- orionis/console/commands/version.py +2 -2
- orionis/console/core/reactor.py +1 -1
- orionis/foundation/config/roots/paths.py +2 -2
- orionis/metadata/framework.py +38 -65
- orionis/metadata/package.py +280 -54
- orionis/support/entities/base.py +18 -37
- orionis/support/facades/console.py +3 -9
- orionis/support/facades/dumper.py +3 -9
- orionis/support/facades/logger.py +3 -9
- orionis/support/facades/path_resolver.py +3 -10
- orionis/support/facades/progress_bar.py +3 -10
- orionis/support/facades/testing.py +4 -10
- orionis/support/facades/workers.py +4 -9
- orionis/support/formatter/exceptions/contracts/parser.py +10 -7
- orionis/support/formatter/exceptions/parser.py +28 -26
- orionis/support/formatter/serializer.py +12 -5
- orionis/support/patterns/singleton/meta.py +17 -21
- orionis/support/standard/contracts/std.py +25 -24
- orionis/support/standard/exceptions/value.py +2 -2
- orionis/support/standard/std.py +26 -24
- orionis/support/wrapper/dot_dict.py +16 -51
- orionis/test/cases/asynchronous.py +17 -81
- orionis/test/cases/synchronous.py +17 -73
- orionis/test/contracts/dumper.py +17 -21
- orionis/test/contracts/kernel.py +5 -12
- orionis/test/contracts/logs.py +16 -21
- orionis/test/contracts/printer.py +70 -8
- orionis/test/contracts/render.py +7 -13
- orionis/test/contracts/test_result.py +58 -27
- orionis/test/contracts/unit_test.py +18 -18
- orionis/test/core/unit_test.py +162 -519
- orionis/test/entities/result.py +49 -21
- orionis/test/enums/status.py +11 -17
- orionis/test/exceptions/config.py +4 -8
- orionis/test/exceptions/failure.py +2 -18
- orionis/test/exceptions/persistence.py +4 -8
- orionis/test/exceptions/runtime.py +4 -8
- orionis/test/exceptions/value.py +5 -13
- orionis/test/kernel.py +14 -42
- orionis/test/output/dumper.py +21 -43
- orionis/test/output/printer.py +6 -146
- orionis/test/records/logs.py +57 -121
- orionis/test/validators/base_path.py +8 -6
- orionis/test/validators/execution_mode.py +2 -3
- orionis/test/validators/fail_fast.py +4 -8
- orionis/test/validators/folder_path.py +5 -7
- orionis/test/validators/module_name.py +3 -3
- orionis/test/validators/name_pattern.py +4 -9
- orionis/test/validators/pattern.py +4 -9
- orionis/test/validators/persistent.py +4 -14
- orionis/test/validators/persistent_driver.py +7 -12
- orionis/test/validators/print_result.py +4 -9
- orionis/test/validators/tags.py +6 -7
- orionis/test/validators/throw_exception.py +7 -14
- orionis/test/validators/verbosity.py +15 -5
- orionis/test/validators/web_report.py +6 -10
- orionis/test/validators/workers.py +9 -4
- orionis/test/view/render.py +9 -26
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/METADATA +1 -1
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/RECORD +82 -81
- tests/metadata/test_metadata_framework.py +64 -90
- tests/metadata/test_metadata_package.py +31 -31
- tests/support/entities/mock_dataclass.py +16 -10
- tests/support/entities/test_base.py +6 -14
- tests/support/patterns/singleton/test_patterns_singleton.py +7 -8
- tests/support/standard/test_services_std.py +113 -37
- tests/support/wrapper/test_services_wrapper_docdict.py +25 -40
- tests/testing/cases/test_testing_asynchronous.py +14 -14
- tests/testing/cases/test_testing_synchronous.py +12 -14
- tests/testing/entities/test_testing_result.py +12 -51
- tests/testing/enums/test_testing_status.py +8 -13
- tests/testing/output/test_testing_dumper.py +3 -6
- tests/testing/output/test_testing_printer.py +5 -5
- tests/testing/records/test_testing_records.py +16 -26
- tests/testing/test_testing_unit.py +8 -94
- tests/testing/validators/test_testing_validators.py +55 -112
- tests/testing/view/test_render.py +4 -5
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/WHEEL +0 -0
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/top_level.txt +0 -0
- {orionis-0.431.0.dist-info → orionis-0.434.0.dist-info}/zip-safe +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
2
2
|
from unittest.mock import patch
|
|
3
3
|
|
|
4
|
-
class
|
|
4
|
+
class TestPypiOrionisPackage(AsyncTestCase):
|
|
5
5
|
|
|
6
|
-
@patch("orionis.metadata.package.
|
|
7
|
-
async def testGetName(self,
|
|
6
|
+
@patch("orionis.metadata.package.PypiOrionisPackage")
|
|
7
|
+
async def testGetName(self, MockPypiOrionisPackage):
|
|
8
8
|
"""
|
|
9
|
-
Tests the `getName` method of the `
|
|
9
|
+
Tests the `getName` method of the `PypiOrionisPackage` class.
|
|
10
10
|
|
|
11
11
|
This test verifies that the mocked `getName` method returns the expected package name.
|
|
12
12
|
|
|
13
13
|
Parameters
|
|
14
14
|
----------
|
|
15
|
-
|
|
16
|
-
Mocked `
|
|
15
|
+
MockPypiOrionisPackage : MagicMock
|
|
16
|
+
Mocked `PypiOrionisPackage` class.
|
|
17
17
|
|
|
18
18
|
Returns
|
|
19
19
|
-------
|
|
@@ -22,7 +22,7 @@ class TestPypiPackageApi(AsyncTestCase):
|
|
|
22
22
|
"""
|
|
23
23
|
|
|
24
24
|
# Get the mocked API instance
|
|
25
|
-
api =
|
|
25
|
+
api = MockPypiOrionisPackage.return_value
|
|
26
26
|
|
|
27
27
|
# Set the return value for getName
|
|
28
28
|
api.getName.return_value = "orionis"
|
|
@@ -30,17 +30,17 @@ class TestPypiPackageApi(AsyncTestCase):
|
|
|
30
30
|
# Assert that getName returns the expected value
|
|
31
31
|
self.assertEqual(api.getName(), "orionis")
|
|
32
32
|
|
|
33
|
-
@patch("orionis.metadata.package.
|
|
34
|
-
async def testGetAuthor(self,
|
|
33
|
+
@patch("orionis.metadata.package.PypiOrionisPackage")
|
|
34
|
+
async def testGetAuthor(self, MockPypiOrionisPackage):
|
|
35
35
|
"""
|
|
36
|
-
Tests the `getAuthor` method of the `
|
|
36
|
+
Tests the `getAuthor` method of the `PypiOrionisPackage` class.
|
|
37
37
|
|
|
38
38
|
This test checks that the mocked `getAuthor` method returns the correct author name.
|
|
39
39
|
|
|
40
40
|
Parameters
|
|
41
41
|
----------
|
|
42
|
-
|
|
43
|
-
Mocked `
|
|
42
|
+
MockPypiOrionisPackage : MagicMock
|
|
43
|
+
Mocked `PypiOrionisPackage` class.
|
|
44
44
|
|
|
45
45
|
Returns
|
|
46
46
|
-------
|
|
@@ -49,7 +49,7 @@ class TestPypiPackageApi(AsyncTestCase):
|
|
|
49
49
|
"""
|
|
50
50
|
|
|
51
51
|
# Get the mocked API instance
|
|
52
|
-
api =
|
|
52
|
+
api = MockPypiOrionisPackage.return_value
|
|
53
53
|
|
|
54
54
|
# Set the return value for getAuthor
|
|
55
55
|
api.getAuthor.return_value = "Raul Mauricio Uñate Castro"
|
|
@@ -57,17 +57,17 @@ class TestPypiPackageApi(AsyncTestCase):
|
|
|
57
57
|
# Assert that getAuthor returns the expected value
|
|
58
58
|
self.assertEqual(api.getAuthor(), "Raul Mauricio Uñate Castro")
|
|
59
59
|
|
|
60
|
-
@patch("orionis.metadata.package.
|
|
61
|
-
async def testGetAuthorEmail(self,
|
|
60
|
+
@patch("orionis.metadata.package.PypiOrionisPackage")
|
|
61
|
+
async def testGetAuthorEmail(self, MockPypiOrionisPackage):
|
|
62
62
|
"""
|
|
63
|
-
Tests the `getAuthorEmail` method of the `
|
|
63
|
+
Tests the `getAuthorEmail` method of the `PypiOrionisPackage` class.
|
|
64
64
|
|
|
65
65
|
This test ensures that the mocked `getAuthorEmail` method returns the correct author email address.
|
|
66
66
|
|
|
67
67
|
Parameters
|
|
68
68
|
----------
|
|
69
|
-
|
|
70
|
-
Mocked `
|
|
69
|
+
MockPypiOrionisPackage : MagicMock
|
|
70
|
+
Mocked `PypiOrionisPackage` class.
|
|
71
71
|
|
|
72
72
|
Returns
|
|
73
73
|
-------
|
|
@@ -76,7 +76,7 @@ class TestPypiPackageApi(AsyncTestCase):
|
|
|
76
76
|
"""
|
|
77
77
|
|
|
78
78
|
# Get the mocked API instance
|
|
79
|
-
api =
|
|
79
|
+
api = MockPypiOrionisPackage.return_value
|
|
80
80
|
|
|
81
81
|
# Set the return value for getAuthorEmail
|
|
82
82
|
api.getAuthorEmail.return_value = "raulmauriciounate@gmail.com"
|
|
@@ -84,17 +84,17 @@ class TestPypiPackageApi(AsyncTestCase):
|
|
|
84
84
|
# Assert that getAuthorEmail returns the expected value
|
|
85
85
|
self.assertEqual(api.getAuthorEmail(), "raulmauriciounate@gmail.com")
|
|
86
86
|
|
|
87
|
-
@patch("orionis.metadata.package.
|
|
88
|
-
async def testGetDescription(self,
|
|
87
|
+
@patch("orionis.metadata.package.PypiOrionisPackage")
|
|
88
|
+
async def testGetDescription(self, MockPypiOrionisPackage):
|
|
89
89
|
"""
|
|
90
|
-
Tests the `getDescription` method of the `
|
|
90
|
+
Tests the `getDescription` method of the `PypiOrionisPackage` class.
|
|
91
91
|
|
|
92
92
|
This test verifies that the mocked `getDescription` method returns the expected package description.
|
|
93
93
|
|
|
94
94
|
Parameters
|
|
95
95
|
----------
|
|
96
|
-
|
|
97
|
-
Mocked `
|
|
96
|
+
MockPypiOrionisPackage : MagicMock
|
|
97
|
+
Mocked `PypiOrionisPackage` class.
|
|
98
98
|
|
|
99
99
|
Returns
|
|
100
100
|
-------
|
|
@@ -103,7 +103,7 @@ class TestPypiPackageApi(AsyncTestCase):
|
|
|
103
103
|
"""
|
|
104
104
|
|
|
105
105
|
# Get the mocked API instance
|
|
106
|
-
api =
|
|
106
|
+
api = MockPypiOrionisPackage.return_value
|
|
107
107
|
|
|
108
108
|
# Set the return value for getDescription
|
|
109
109
|
api.getDescription.return_value = "Orionis Framework – Elegant, Fast, and Powerful."
|
|
@@ -111,17 +111,17 @@ class TestPypiPackageApi(AsyncTestCase):
|
|
|
111
111
|
# Assert that getDescription returns the expected value
|
|
112
112
|
self.assertEqual(api.getDescription(), "Orionis Framework – Elegant, Fast, and Powerful.")
|
|
113
113
|
|
|
114
|
-
@patch("orionis.metadata.package.
|
|
115
|
-
async def testGetPythonVersion(self,
|
|
114
|
+
@patch("orionis.metadata.package.PypiOrionisPackage")
|
|
115
|
+
async def testGetPythonVersion(self, MockPypiOrionisPackage):
|
|
116
116
|
"""
|
|
117
|
-
Tests the `getPythonVersion` method of the `
|
|
117
|
+
Tests the `getPythonVersion` method of the `PypiOrionisPackage` class.
|
|
118
118
|
|
|
119
119
|
This test checks that the mocked `getPythonVersion` method returns the correct Python version requirement.
|
|
120
120
|
|
|
121
121
|
Parameters
|
|
122
122
|
----------
|
|
123
|
-
|
|
124
|
-
Mocked `
|
|
123
|
+
MockPypiOrionisPackage : MagicMock
|
|
124
|
+
Mocked `PypiOrionisPackage` class.
|
|
125
125
|
|
|
126
126
|
Returns
|
|
127
127
|
-------
|
|
@@ -130,7 +130,7 @@ class TestPypiPackageApi(AsyncTestCase):
|
|
|
130
130
|
"""
|
|
131
131
|
|
|
132
132
|
# Get the mocked API instance
|
|
133
|
-
api =
|
|
133
|
+
api = MockPypiOrionisPackage.return_value
|
|
134
134
|
|
|
135
135
|
# Set the return value for getPythonVersion
|
|
136
136
|
api.getPythonVersion.return_value = ">=3.12"
|
|
@@ -10,7 +10,18 @@ class Color(Enum):
|
|
|
10
10
|
@dataclass
|
|
11
11
|
class ExampleEntity(BaseEntity):
|
|
12
12
|
"""
|
|
13
|
-
|
|
13
|
+
Data structure representing an example entity with an identifier, name, color, and tags.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
id : int, optional
|
|
18
|
+
Unique identifier for the entity. Default is 0.
|
|
19
|
+
name : str, optional
|
|
20
|
+
Name of the entity. Default is 'default'.
|
|
21
|
+
color : Color, optional
|
|
22
|
+
Color associated with the entity. Default is Color.RED.
|
|
23
|
+
tags : list, optional
|
|
24
|
+
List of tags associated with the entity. Default is an empty list.
|
|
14
25
|
|
|
15
26
|
Attributes
|
|
16
27
|
----------
|
|
@@ -22,13 +33,8 @@ class ExampleEntity(BaseEntity):
|
|
|
22
33
|
Color associated with the entity.
|
|
23
34
|
tags : list
|
|
24
35
|
List of tags associated with the entity.
|
|
25
|
-
|
|
26
|
-
Returns
|
|
27
|
-
-------
|
|
28
|
-
ExampleEntity
|
|
29
|
-
An instance of ExampleEntity with specified attributes.
|
|
30
36
|
"""
|
|
31
|
-
id: int = 0
|
|
32
|
-
name: str = "default"
|
|
33
|
-
color: Color = Color.RED
|
|
34
|
-
tags: list = field(default_factory=list, metadata={"default": ["tag1", "tag2"]})
|
|
37
|
+
id: int = 0 # Default id is 0
|
|
38
|
+
name: str = "default" # Default name is 'default'
|
|
39
|
+
color: Color = Color.RED # Default color is RED
|
|
40
|
+
tags: list = field(default_factory=list, metadata={"default": ["tag1", "tag2"]}) # Default tags list
|
|
@@ -5,32 +5,27 @@ class TestBaseEntity(AsyncTestCase):
|
|
|
5
5
|
|
|
6
6
|
async def asyncSetUp(self):
|
|
7
7
|
"""
|
|
8
|
-
|
|
8
|
+
Asynchronously initializes the test environment before each test.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
It creates an ExampleEntity with predefined attributes.
|
|
10
|
+
Initializes an ExampleEntity instance with predefined attributes and assigns it to self.entity.
|
|
12
11
|
|
|
13
12
|
Returns
|
|
14
13
|
-------
|
|
15
14
|
None
|
|
16
|
-
This method does not return any value.
|
|
17
15
|
"""
|
|
18
16
|
# Create an ExampleEntity instance for use in tests
|
|
19
17
|
self.entity = ExampleEntity(id=42, name="test", color=Color.GREEN, tags=["a", "b"])
|
|
20
18
|
|
|
21
19
|
async def testToDict(self):
|
|
22
20
|
"""
|
|
23
|
-
|
|
21
|
+
Tests the toDict method of ExampleEntity.
|
|
24
22
|
|
|
25
|
-
Verifies that
|
|
26
|
-
with correct field values.
|
|
23
|
+
Verifies that toDict returns a dictionary with correct field values for the entity.
|
|
27
24
|
|
|
28
25
|
Returns
|
|
29
26
|
-------
|
|
30
27
|
None
|
|
31
|
-
This method does not return any value.
|
|
32
28
|
"""
|
|
33
|
-
|
|
34
29
|
# Convert entity to dictionary
|
|
35
30
|
result = self.entity.toDict()
|
|
36
31
|
self.assertIsInstance(result, dict)
|
|
@@ -43,17 +38,14 @@ class TestBaseEntity(AsyncTestCase):
|
|
|
43
38
|
|
|
44
39
|
async def testGetFields(self):
|
|
45
40
|
"""
|
|
46
|
-
|
|
41
|
+
Tests the getFields method of ExampleEntity.
|
|
47
42
|
|
|
48
|
-
Ensures
|
|
49
|
-
each containing field name, types, default value, and metadata.
|
|
43
|
+
Ensures getFields returns a list of dictionaries, each containing field name, types, default value, and metadata.
|
|
50
44
|
|
|
51
45
|
Returns
|
|
52
46
|
-------
|
|
53
47
|
None
|
|
54
|
-
This method does not return any value.
|
|
55
48
|
"""
|
|
56
|
-
|
|
57
49
|
# Retrieve field information from entity
|
|
58
50
|
fields_info = self.entity.getFields()
|
|
59
51
|
self.assertIsInstance(fields_info, list)
|
|
@@ -5,22 +5,21 @@ class TestPatternsSingleton(AsyncTestCase):
|
|
|
5
5
|
|
|
6
6
|
async def testSingleton(self):
|
|
7
7
|
"""
|
|
8
|
-
|
|
8
|
+
Test the Singleton metaclass to ensure only one instance is created.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
regardless of how many times it is instantiated.
|
|
12
|
-
singleton instance
|
|
10
|
+
This test verifies that a class using the Singleton metaclass will always return
|
|
11
|
+
the same instance, regardless of how many times it is instantiated. It also checks
|
|
12
|
+
that the initial state of the singleton instance does not change after subsequent
|
|
13
|
+
instantiations with different arguments.
|
|
13
14
|
|
|
14
15
|
Parameters
|
|
15
16
|
----------
|
|
16
17
|
self : TestPatternsSingleton
|
|
17
|
-
|
|
18
|
+
Instance of the test case.
|
|
18
19
|
|
|
19
20
|
Returns
|
|
20
21
|
-------
|
|
21
22
|
None
|
|
22
|
-
This method does not return any value. Assertions are used to verify singleton behavior.
|
|
23
|
-
|
|
24
23
|
"""
|
|
25
24
|
# Define a class using the Singleton metaclass
|
|
26
25
|
class SingletonClass(metaclass=Singleton):
|
|
@@ -37,4 +36,4 @@ class TestPatternsSingleton(AsyncTestCase):
|
|
|
37
36
|
self.assertIs(instance1, instance2)
|
|
38
37
|
|
|
39
38
|
# Assert that the value remains as set by the first instantiation
|
|
40
|
-
self.assertEqual(instance1.value, 1)
|
|
39
|
+
self.assertEqual(instance1.value, 1)
|
|
@@ -6,13 +6,21 @@ class TestSupportStd(AsyncTestCase):
|
|
|
6
6
|
|
|
7
7
|
async def testInitializationAndAccess(self):
|
|
8
8
|
"""
|
|
9
|
-
Test
|
|
9
|
+
Test initialization and attribute access of StdClass.
|
|
10
|
+
|
|
11
|
+
Parameters
|
|
12
|
+
----------
|
|
13
|
+
self : TestSupportStd
|
|
14
|
+
The test case instance.
|
|
15
|
+
|
|
16
|
+
Returns
|
|
17
|
+
-------
|
|
18
|
+
None
|
|
10
19
|
|
|
11
20
|
Notes
|
|
12
21
|
-----
|
|
13
|
-
Verifies that
|
|
14
|
-
|
|
15
|
-
correctly after initialization.
|
|
22
|
+
Verifies that StdClass can be instantiated with specific attributes and
|
|
23
|
+
that those attributes are accessible after initialization.
|
|
16
24
|
"""
|
|
17
25
|
obj = StdClass(
|
|
18
26
|
first_name='Raul',
|
|
@@ -24,12 +32,20 @@ class TestSupportStd(AsyncTestCase):
|
|
|
24
32
|
|
|
25
33
|
async def testToDictReturnsCorrectData(self):
|
|
26
34
|
"""
|
|
27
|
-
Test that
|
|
35
|
+
Test that StdClass.toDict returns a dictionary with correct attribute data.
|
|
36
|
+
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
self : TestSupportStd
|
|
40
|
+
The test case instance.
|
|
41
|
+
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
None
|
|
28
45
|
|
|
29
46
|
Notes
|
|
30
47
|
-----
|
|
31
|
-
|
|
32
|
-
that calling toDict() returns a dictionary containing those attributes and their values.
|
|
48
|
+
Ensures that toDict() returns a dictionary containing all attributes and their values.
|
|
33
49
|
"""
|
|
34
50
|
obj = StdClass(a=1, b=2)
|
|
35
51
|
expected = {'a': 1, 'b': 2}
|
|
@@ -37,12 +53,20 @@ class TestSupportStd(AsyncTestCase):
|
|
|
37
53
|
|
|
38
54
|
async def testUpdateAttributes(self):
|
|
39
55
|
"""
|
|
40
|
-
Test
|
|
56
|
+
Test updating multiple attributes using StdClass.update.
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
self : TestSupportStd
|
|
61
|
+
The test case instance.
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
None
|
|
41
66
|
|
|
42
67
|
Notes
|
|
43
68
|
-----
|
|
44
|
-
|
|
45
|
-
and asserts that the attributes `foo` and `number` are set to the expected values.
|
|
69
|
+
Verifies that update() sets multiple attributes as expected.
|
|
46
70
|
"""
|
|
47
71
|
obj = StdClass()
|
|
48
72
|
obj.update(foo='bar', number=42)
|
|
@@ -51,12 +75,21 @@ class TestSupportStd(AsyncTestCase):
|
|
|
51
75
|
|
|
52
76
|
async def testUpdateReservedAttributeRaisesError(self):
|
|
53
77
|
"""
|
|
54
|
-
Test that updating a reserved attribute
|
|
55
|
-
|
|
78
|
+
Test that updating a reserved attribute raises OrionisStdValueException.
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
self : TestSupportStd
|
|
83
|
+
The test case instance.
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
None
|
|
56
88
|
|
|
57
89
|
Notes
|
|
58
90
|
-----
|
|
59
|
-
Ensures that
|
|
91
|
+
Ensures that attempting to update a reserved attribute (e.g., '__init__')
|
|
92
|
+
raises the appropriate exception.
|
|
60
93
|
"""
|
|
61
94
|
obj = StdClass()
|
|
62
95
|
with self.assertRaises(OrionisStdValueException):
|
|
@@ -64,13 +97,21 @@ class TestSupportStd(AsyncTestCase):
|
|
|
64
97
|
|
|
65
98
|
async def testUpdateConflictingAttributeRaisesError(self):
|
|
66
99
|
"""
|
|
67
|
-
Test that updating
|
|
100
|
+
Test that updating with a conflicting attribute name raises OrionisStdValueException.
|
|
101
|
+
|
|
102
|
+
Parameters
|
|
103
|
+
----------
|
|
104
|
+
self : TestSupportStd
|
|
105
|
+
The test case instance.
|
|
106
|
+
|
|
107
|
+
Returns
|
|
108
|
+
-------
|
|
109
|
+
None
|
|
68
110
|
|
|
69
111
|
Notes
|
|
70
112
|
-----
|
|
71
|
-
Ensures that
|
|
72
|
-
|
|
73
|
-
an OrionisStdValueException, enforcing attribute safety.
|
|
113
|
+
Ensures that updating with a name that conflicts with an existing method
|
|
114
|
+
or reserved attribute (e.g., 'toDict') raises an exception.
|
|
74
115
|
"""
|
|
75
116
|
obj = StdClass()
|
|
76
117
|
with self.assertRaises(OrionisStdValueException):
|
|
@@ -78,11 +119,20 @@ class TestSupportStd(AsyncTestCase):
|
|
|
78
119
|
|
|
79
120
|
async def testRemoveExistingAttributes(self):
|
|
80
121
|
"""
|
|
81
|
-
Test
|
|
122
|
+
Test removal of an existing attribute using StdClass.remove.
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
self : TestSupportStd
|
|
127
|
+
The test case instance.
|
|
128
|
+
|
|
129
|
+
Returns
|
|
130
|
+
-------
|
|
131
|
+
None
|
|
82
132
|
|
|
83
133
|
Notes
|
|
84
134
|
-----
|
|
85
|
-
Removes attribute
|
|
135
|
+
Removes an attribute and checks that it no longer exists, while others remain.
|
|
86
136
|
"""
|
|
87
137
|
obj = StdClass(x=1, y=2)
|
|
88
138
|
obj.remove('x')
|
|
@@ -91,12 +141,20 @@ class TestSupportStd(AsyncTestCase):
|
|
|
91
141
|
|
|
92
142
|
async def testRemoveNonExistingAttributeRaisesError(self):
|
|
93
143
|
"""
|
|
94
|
-
Test that
|
|
144
|
+
Test that removing a non-existing attribute raises AttributeError.
|
|
145
|
+
|
|
146
|
+
Parameters
|
|
147
|
+
----------
|
|
148
|
+
self : TestSupportStd
|
|
149
|
+
The test case instance.
|
|
150
|
+
|
|
151
|
+
Returns
|
|
152
|
+
-------
|
|
153
|
+
None
|
|
95
154
|
|
|
96
155
|
Notes
|
|
97
156
|
-----
|
|
98
|
-
|
|
99
|
-
when called with the name of an attribute that does not exist on the object.
|
|
157
|
+
Ensures that attempting to remove an attribute that does not exist raises an error.
|
|
100
158
|
"""
|
|
101
159
|
obj = StdClass()
|
|
102
160
|
with self.assertRaises(AttributeError):
|
|
@@ -104,12 +162,20 @@ class TestSupportStd(AsyncTestCase):
|
|
|
104
162
|
|
|
105
163
|
async def testFromDictCreatesEquivalentInstance(self):
|
|
106
164
|
"""
|
|
107
|
-
Test
|
|
165
|
+
Test creation of StdClass instance from a dictionary using fromDict.
|
|
166
|
+
|
|
167
|
+
Parameters
|
|
168
|
+
----------
|
|
169
|
+
self : TestSupportStd
|
|
170
|
+
The test case instance.
|
|
171
|
+
|
|
172
|
+
Returns
|
|
173
|
+
-------
|
|
174
|
+
None
|
|
108
175
|
|
|
109
176
|
Notes
|
|
110
177
|
-----
|
|
111
|
-
Verifies that
|
|
112
|
-
the resulting object's toDict() method returns a dictionary equal to the original input.
|
|
178
|
+
Verifies that fromDict creates an instance whose attributes match the input dictionary.
|
|
113
179
|
"""
|
|
114
180
|
data = {'a': 10, 'b': 20}
|
|
115
181
|
obj = StdClass.fromDict(data)
|
|
@@ -117,12 +183,20 @@ class TestSupportStd(AsyncTestCase):
|
|
|
117
183
|
|
|
118
184
|
async def testReprAndStr(self):
|
|
119
185
|
"""
|
|
120
|
-
Test
|
|
186
|
+
Test __repr__ and __str__ methods of StdClass for expected output.
|
|
187
|
+
|
|
188
|
+
Parameters
|
|
189
|
+
----------
|
|
190
|
+
self : TestSupportStd
|
|
191
|
+
The test case instance.
|
|
192
|
+
|
|
193
|
+
Returns
|
|
194
|
+
-------
|
|
195
|
+
None
|
|
121
196
|
|
|
122
197
|
Notes
|
|
123
198
|
-----
|
|
124
|
-
|
|
125
|
-
- Checks that str(obj) contains the key-value pair "'x': 5".
|
|
199
|
+
Checks that __repr__ includes the class name and __str__ includes attribute key-value pairs.
|
|
126
200
|
"""
|
|
127
201
|
obj = StdClass(x=5)
|
|
128
202
|
self.assertIn("StdClass", repr(obj))
|
|
@@ -130,18 +204,20 @@ class TestSupportStd(AsyncTestCase):
|
|
|
130
204
|
|
|
131
205
|
async def testEquality(self):
|
|
132
206
|
"""
|
|
133
|
-
Test
|
|
207
|
+
Test equality and inequality operations for StdClass instances.
|
|
134
208
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
- 'c' with a different attribute (x=3), which should not be equal to 'a'.
|
|
209
|
+
Parameters
|
|
210
|
+
----------
|
|
211
|
+
self : TestSupportStd
|
|
212
|
+
The test case instance.
|
|
140
213
|
|
|
141
|
-
|
|
214
|
+
Returns
|
|
142
215
|
-------
|
|
143
|
-
|
|
144
|
-
|
|
216
|
+
None
|
|
217
|
+
|
|
218
|
+
Notes
|
|
219
|
+
-----
|
|
220
|
+
Verifies that instances with identical attributes are equal and those with different attributes are not.
|
|
145
221
|
"""
|
|
146
222
|
a = StdClass(x=1, y=2)
|
|
147
223
|
b = StdClass(x=1, y=2)
|