Commit da3634c
authored
Enhance COM Moniker, Bind Context and Running Object Table Test Coverage (#912)
* test: Add `Test_IsEqual` for moniker comparison in `test_moniker.py`
Introduces `Test_IsEqual` class to `test/test_moniker.py` to verify the correct
functionality of `IsEqual` method for monikers. This test ensures that monikers
with identical item IDs are correctly identified as equal, while those with
different item IDs are not.
* test: Add `Test_Hash` for moniker hash comparison in `test_moniker.py`
Introduces `Test_Hash` class to `test/test_moniker.py` to verify the correct
functionality of the `Hash` method for monikers. This test ensures that
monikers with identical item IDs produce the same hash value, while those with
different item IDs produce different hash values.
* test: Add `Test_ComposeWith` for moniker composition and error handling
Introduces `Test_ComposeWith` to `test/test_moniker.py` to verify the
`ComposeWith` method. This test ensures that composing item monikers results in
a `CLSID_CompositeMoniker`.
It also validates that when `fOnlyIfNotGeneric=True`, `ComposeWith` correctly
raises a `COMError` with `MK_E_NEEDGENERIC`, indicating that the moniker cannot
be composed generically.
Constants `CLSID_CompositeMoniker` and `MK_E_NEEDGENERIC` were added to
`test/monikers_helper.py` to support this test.
* test: Add `Test_Enum` for composite moniker enumeration
Introduces `Test_Enum` class with `test_generic_composite` method to
`test/test_moniker.py`. This test verifies the `Enum` method of composite
monikers, ensuring it correctly returns an `IEnumMoniker` instance. It uses the
newly added `_CreateGenericComposite` helper in `test/monikers_helper.py`.
* test: Add `test_generic_composite` to `test_moniker.py`
This test verifies the correct behavior of `IsSystemMoniker`, `GetDisplayName`,
`GetClassID`, and `Inverse` methods for generic composite monikers.
The `MKSYS_GENERICCOMPOSITE` constant was added to `monikers_helper.py` to
support this test.
* test: Add `Test_RemoteBindToObject` for file moniker binding
Introduces `Test_RemoteBindToObject` class with `test_file` method to
`test/test_moniker.py`. This test verifies the `RemoteBindToObject` method for
file monikers, ensuring correct binding to `IPersistFile`.
The `_CreateFileMoniker` helper function was added to `monikers_helper.py` to
support this test.
* test: Add `test_file` for `IsSystemMoniker` to `test_moniker.py`
Introduces `test_file` method to `Test_IsSystemMoniker_GetDisplayName_Inverse`
in `test/test_moniker.py`. This test verifies the correct behavior of
`IsSystemMoniker`, `GetDisplayName`, `GetClassID`, and `Inverse` methods for
file monikers. The `MKSYS_FILEMONIKER` and `CLSID_FileMoniker` constants were
added to `monikers_helper.py` to support this test.
* test: Add `Test_CommonPrefixWith` for moniker common prefix detection
Introduces `Test_CommonPrefixWith` class with `test_file` method to
`test/test_moniker.py`. This test verifies the `CommonPrefixWith` method for
file monikers, ensuring it correctly identifies the common directory path
between different file monikers.
* test: Add `Test_RelativePathTo` for moniker relative path calculation
Introduces `Test_RelativePathTo` class with `test_file` method to
`/test/test_moniker.py`. This test verifies the `RelativePathTo` method for
file monikers, ensuring it correctly calculates the relative path between two
file monikers, mirroring `pathlib.Path.relative_to`.
* test: Add tests for `IBindCtx.RemoteSetBindOptions` and `RemoteGetBindOptions`.
This commit introduces a new test class `Test_Set_Get_BindOptions` to
`test/test_bctx.py`. It verifies the correct functionality of `SetBindOptions`
and `GetBindOptions` by setting and retrieving `tagBIND_OPTS2` values and
asserting their correctness.
* test: Add tests for `IBindCtx` object parameter (`...ObjectParam`) methods.
This commit introduces a new test class `Test_Get_Register_Revoke_ObjectParam`
to `test/test_bctx.py`. It verifies the functionality of `GetObjectParam`,
`RegisterObjectParam`, and `RevokeObjectParam` by registering and revoking a
COM object and asserting its presence or absence.
* test: Add tests for `IBindCtx` bound object (`...ObjectBound`) methods.
This commit introduces a new test class to `test/test_bctx.py`.
It verifies the functionality of `RegisterObjectBound`, `RevokeObjectBound`,
and `ReleaseBoundObjects` by registering and unregistering a COM object within
the bind context.
* test: Add test for `IRunningObjectTable.EnumRunning` method.
* fix: Resolve path comparison issues in `test_moniker.py`
Add `_get_long_path_name` to `test_moniker.py`.
This change ensures consistent path normalization across test environments,
preventing failures due to short path vs. long path discrepancies.
* fix: Simplify relative path comparison in `test_moniker.py`
Replaced the dynamic calculation of relative paths using `Path.relative_to`
with a literal string in `Test_RelativePathTo.test_file`.
This simplifies the test logic and resolves the `TypeError` caused by
`walk_up=True` in older Python environments, aligning with the goal of reducing
complexity.1 parent 526af9a commit da3634c
4 files changed
Lines changed: 312 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
18 | 34 | | |
19 | 35 | | |
20 | 36 | | |
| |||
28 | 44 | | |
29 | 45 | | |
30 | 46 | | |
| 47 | + | |
31 | 48 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
4 | 10 | | |
5 | 11 | | |
6 | 12 | | |
| 13 | + | |
7 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
8 | 18 | | |
9 | 19 | | |
10 | 20 | | |
| 21 | + | |
| 22 | + | |
11 | 23 | | |
12 | 24 | | |
| 25 | + | |
| 26 | + | |
13 | 27 | | |
14 | 28 | | |
15 | 29 | | |
16 | 30 | | |
17 | 31 | | |
18 | 32 | | |
19 | 33 | | |
20 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
21 | 65 | | |
22 | 66 | | |
23 | 67 | | |
| |||
41 | 85 | | |
42 | 86 | | |
43 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
44 | 117 | | |
45 | 118 | | |
46 | 119 | | |
| |||
51 | 124 | | |
52 | 125 | | |
53 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
54 | 162 | | |
55 | 163 | | |
56 | 164 | | |
| |||
66 | 174 | | |
67 | 175 | | |
68 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
0 commit comments