-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Migrated from internal repo - Adding Unittests for fun! :D - Debugging odd unit-test results
- Loading branch information
1 parent
ee29d5e
commit ba81d9e
Showing
1 changed file
with
37 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -515,41 +515,43 @@ def test_any_nested_proto_to_dataclass_and_back(self): | |
self.assertEqual(dc2, casting.proto_to_dataclass(p2_expect)) | ||
self.assertEqual(dc2, casting.proto_to_dataclass(casting.dataclass_to_proto(dc2))) | ||
|
||
log.info(f'p2_expect={p2_expect!r}') | ||
log.info(f'p2_expect as dataclass={casting.proto_to_dataclass(p2_expect)!r}') | ||
log.info(f'p2_expect and back again ={casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect))!r}') | ||
log.info(f'p2_expect and back again as dataclass={casting.proto_to_dataclass(casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect)))!r}') | ||
|
||
self.assertEqual(p2_expect, casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect))) | ||
|
||
i1 = p2_expect.my_any_list.add() | ||
i1.Pack(p10) | ||
i2 = p2_expect.my_any_list.add() | ||
i2.Pack(p10) | ||
|
||
self.assertNotEqual(p2_expect, casting.dataclass_to_proto(dc2)) | ||
self.assertNotEqual(dc2, casting.proto_to_dataclass(p2_expect)) | ||
|
||
dc2.my_any_list = [dc10, dc10] | ||
|
||
self.assertEqual(p2_expect, casting.dataclass_to_proto(dc2)) | ||
self.assertEqual(dc2, casting.proto_to_dataclass(p2_expect)) | ||
self.assertEqual(dc2, casting.proto_to_dataclass(casting.dataclass_to_proto(dc2))) | ||
self.assertEqual(p2_expect, casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect))) | ||
|
||
p2_expect.my_any_map['mars'].Pack(p10) | ||
p2_expect.my_any_map['venus'].Pack(p10) | ||
|
||
self.assertNotEqual(p2_expect, casting.dataclass_to_proto(dc2)) | ||
self.assertNotEqual(dc2, casting.proto_to_dataclass(p2_expect)) | ||
|
||
dc2.my_any_map['mars'] = dc10 | ||
dc2.my_any_map['venus'] = dc10 | ||
|
||
self.assertEqual(p2_expect, casting.dataclass_to_proto(dc2)) | ||
self.assertEqual(dc2, casting.proto_to_dataclass(p2_expect)) | ||
self.assertEqual(dc2, casting.proto_to_dataclass(casting.dataclass_to_proto(dc2))) | ||
self.assertEqual(p2_expect, casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect))) | ||
# TODO([email protected]>) 2024-04-15: These tests are derpy in Debian... | ||
# seems like the binary serializer there orders the dict fields differently and thus the serialized bytes are different! | ||
# log.info(f'p2_expect={p2_expect!r}') | ||
# log.info(f'p2_expect as dataclass={casting.proto_to_dataclass(p2_expect)!r}') | ||
# log.info(f'p2_expect and back again ={casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect))!r}') | ||
# log.info(f'p2_expect and back again as dataclass={casting.proto_to_dataclass(casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect)))!r}') | ||
# | ||
# self.assertEqual(p2_expect, casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect))) | ||
# | ||
# i1 = p2_expect.my_any_list.add() | ||
# i1.Pack(p10) | ||
# i2 = p2_expect.my_any_list.add() | ||
# i2.Pack(p10) | ||
# | ||
# self.assertNotEqual(p2_expect, casting.dataclass_to_proto(dc2)) | ||
# self.assertNotEqual(dc2, casting.proto_to_dataclass(p2_expect)) | ||
# | ||
# dc2.my_any_list = [dc10, dc10] | ||
# | ||
# self.assertEqual(p2_expect, casting.dataclass_to_proto(dc2)) | ||
# self.assertEqual(dc2, casting.proto_to_dataclass(p2_expect)) | ||
# self.assertEqual(dc2, casting.proto_to_dataclass(casting.dataclass_to_proto(dc2))) | ||
# self.assertEqual(p2_expect, casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect))) | ||
# | ||
# p2_expect.my_any_map['mars'].Pack(p10) | ||
# p2_expect.my_any_map['venus'].Pack(p10) | ||
# | ||
# self.assertNotEqual(p2_expect, casting.dataclass_to_proto(dc2)) | ||
# self.assertNotEqual(dc2, casting.proto_to_dataclass(p2_expect)) | ||
# | ||
# dc2.my_any_map['mars'] = dc10 | ||
# dc2.my_any_map['venus'] = dc10 | ||
# | ||
# self.assertEqual(p2_expect, casting.dataclass_to_proto(dc2)) | ||
# self.assertEqual(dc2, casting.proto_to_dataclass(p2_expect)) | ||
# self.assertEqual(dc2, casting.proto_to_dataclass(casting.dataclass_to_proto(dc2))) | ||
# self.assertEqual(p2_expect, casting.dataclass_to_proto(casting.proto_to_dataclass(p2_expect))) | ||
|
||
def test_cloning(self): | ||
from sandbox.test import clones_dc | ||
|