Skip to content

Commit

Permalink
Update test_dispifc_records.py
Browse files Browse the repository at this point in the history
  • Loading branch information
junkmd authored May 29, 2024
1 parent d62ec76 commit 69b41f1
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions comtypes/test/test_dispifc_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,44 @@ def test_in_record(self):
self.assertEqual(rec.answer, a)
self.assertEqual(rec.needs_clarification, nc)

def test_in_pointer(self):
inited_record = ComtypesCppTestSrvLib.StructRecordParamTest()
inited_record.question = self.EXPECTED_INITED_QUESTIONS
inited_record.answer = 42
inited_record.needs_clarification = True
for rec, expected, (q, a, nc) in [
(inited_record, True, (self.EXPECTED_INITED_QUESTIONS, 42, True)),
# Also perform the inverted test. For this, create a blank record.
(ComtypesCppTestSrvLib.StructRecordParamTest(), False, (None, 0, False)),
]:
with self.subTest(expected=expected, q=q, a=a, nc=nc):
# Perform the check on initialization values.
self.assertEqual(self._create_dispifc().VerifyRecord(pointer(rec)), expected)
self.assertEqual(rec.question, q)
# Check if the 'answer' field is unchanged although the method
# modifies this field on the server side.
self.assertEqual(rec.answer, a)
self.assertEqual(rec.needs_clarification, nc)

def test_in_byref(self):
inited_record = ComtypesCppTestSrvLib.StructRecordParamTest()
inited_record.question = self.EXPECTED_INITED_QUESTIONS
inited_record.answer = 42
inited_record.needs_clarification = True
for rec, expected, (q, a, nc) in [
(inited_record, True, (self.EXPECTED_INITED_QUESTIONS, 42, True)),
# Also perform the inverted test. For this, create a blank record.
(ComtypesCppTestSrvLib.StructRecordParamTest(), False, (None, 0, False)),
]:
with self.subTest(expected=expected, q=q, a=a, nc=nc):
# Perform the check on initialization values.
self.assertEqual(self._create_dispifc().VerifyRecord(byref(rec)), expected)
self.assertEqual(rec.question, q)
# Check if the 'answer' field is unchanged although the method
# modifies this field on the server side.
self.assertEqual(rec.answer, a)
self.assertEqual(rec.needs_clarification, nc)


@unittest.skipIf(IMPORT_FAILED, "This depends on the out of process COM-server.")
class Test_Dual(unittest.TestCase):
Expand Down Expand Up @@ -152,6 +190,44 @@ def test_in_record(self):
self.assertEqual(rec.answer, a)
self.assertEqual(rec.needs_clarification, nc)

def test_in_pointer(self):
inited_record = ComtypesCppTestSrvLib.StructRecordParamTest()
inited_record.question = self.EXPECTED_INITED_QUESTIONS
inited_record.answer = 42
inited_record.needs_clarification = True
for rec, expected, (q, a, nc) in [
(inited_record, True, (self.EXPECTED_INITED_QUESTIONS, 42, True)),
# Also perform the inverted test. For this, create a blank record.
(ComtypesCppTestSrvLib.StructRecordParamTest(), False, (None, 0, False)),
]:
with self.subTest(expected=expected, q=q, a=a, nc=nc):
# Perform the check on initialization values.
self.assertEqual(self._create_dualifc().VerifyRecord(pointer(rec)), expected)
self.assertEqual(rec.question, q)
# Check if the 'answer' field is unchanged although the method
# modifies this field on the server side.
self.assertEqual(rec.answer, a)
self.assertEqual(rec.needs_clarification, nc)

def test_in_byref(self):
inited_record = ComtypesCppTestSrvLib.StructRecordParamTest()
inited_record.question = self.EXPECTED_INITED_QUESTIONS
inited_record.answer = 42
inited_record.needs_clarification = True
for rec, expected, (q, a, nc) in [
(inited_record, True, (self.EXPECTED_INITED_QUESTIONS, 42, True)),
# Also perform the inverted test. For this, create a blank record.
(ComtypesCppTestSrvLib.StructRecordParamTest(), False, (None, 0, False)),
]:
with self.subTest(expected=expected, q=q, a=a, nc=nc):
# Perform the check on initialization values.
self.assertEqual(self._create_dualifc().VerifyRecord(byref(rec)), expected)
self.assertEqual(rec.question, q)
# Check if the 'answer' field is unchanged although the method
# modifies this field on the server side.
self.assertEqual(rec.answer, a)
self.assertEqual(rec.needs_clarification, nc)


if __name__ == "__main__":
unittest.main()

0 comments on commit 69b41f1

Please sign in to comment.