-
Notifications
You must be signed in to change notification settings - Fork 37
Communication worker unit tests #252
Conversation
agslaj-ALock
commented
Feb 8, 2025
- Wrote the communications worker unit test
- Fixed a typo inside communications
maxlou05
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed
tests/unit/test_communications.py
Outdated
| object_in_world_from_position_local(local_position_1), | ||
| object_in_world_from_position_local(local_position_2), | ||
| ] | ||
| number_of_messages = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use len(objects_in_world)
tests/unit/test_communications.py
Outdated
| # Conversion | ||
| result, worker_id, actual_1 = message_encoding_decoding.decode_bytes_to_position_global( | ||
| generated_objects[0] | ||
| ) | ||
| assert result | ||
| assert worker_id is not None | ||
| assert actual_1 is not None | ||
|
|
||
| result, worker_id, actual_2 = message_encoding_decoding.decode_bytes_to_position_global( | ||
| generated_objects[1] | ||
| ) | ||
| assert result | ||
| assert worker_id is not None | ||
| assert actual_2 is not None | ||
|
|
||
| # Test | ||
| assert_global_positions(global_position_1, actual_1) | ||
| assert_global_positions(global_position_2, actual_2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can put this in a loop
tests/unit/test_communications.py
Outdated
|
|
||
| actual = object_in_world_from_position_local(local_position) | ||
| objects_in_world = [actual] | ||
| number_of_messages = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len()
tests/unit/test_communications.py
Outdated
| position = object_in_world_from_position_local(local_position) | ||
|
|
||
| objects_in_world = [position, position, position] | ||
| number_of_messages = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len()
maxlou05
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed
| objects_in_world = objects_in_world or [] | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I realized that we will never receive None as an input, the worker takes care of that and makes sure the type coming in is the same as the type listed above. You can probably remove that test case
tests/unit/test_communications.py
Outdated
| metadata | ||
| ) | ||
| assert result | ||
| assert worker_id is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you assert this is worker_enum.COMMUNICATIONS_WORKER? (Also from common's data_encoding module)
tests/unit/test_communications.py
Outdated
| generated_objects[i] | ||
| ) | ||
| assert result | ||
| assert worker_id is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worker_enum.COMMUNICATIONS_WORKER
tests/unit/test_communications.py
Outdated
| assert actual_number_of_messages == 0 | ||
| assert len(generated_objects) == 0 | ||
|
|
||
| def test_none(self, communications_maker: communications.Communications) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, no need for this lol
tests/unit/test_communications.py
Outdated
| assert metadata is not None | ||
| assert generated_objects is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check types
tests/unit/test_communications.py
Outdated
| metadata | ||
| ) | ||
| assert result | ||
| assert worker_id is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
real value
tests/unit/test_communications.py
Outdated
| ) | ||
| assert result | ||
| assert worker_id is not None | ||
| assert actual_number_of_messages is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
tests/unit/test_communications.py
Outdated
| ) | ||
| assert result | ||
| assert worker_id is not None | ||
| assert actual is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
tests/unit/test_communications.py
Outdated
| generated_object | ||
| ) | ||
| assert result | ||
| assert worker_id is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
real value
maxlou05
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved!