Skip to content

Add can bridge #1923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
435d86d
Add basic implementation for can bridge
pkess Feb 22, 2025
7ec1f52
Implement basic configuration parsing
pkess Feb 22, 2025
441c4da
Add implementation for bridge
pkess Feb 22, 2025
e599f0e
Improve exit handling
pkess Feb 22, 2025
7b18bc6
Add debug logging
pkess Feb 22, 2025
9e3c666
Add error handling for wrong arguments
pkess Feb 22, 2025
8e4bd93
Use stderr
pkess Feb 22, 2025
52703d7
Add custom usage
pkess Feb 22, 2025
0435e17
Add bus configuration info
pkess Feb 22, 2025
8da0ab3
Code format
pkess Feb 23, 2025
9fa9395
Add exception for prints for can_bridge
pkess Feb 23, 2025
3e3dd9e
Add from to exception in exception
pkess Feb 23, 2025
1f2de7d
Remove assignment to unused variable
pkess Feb 23, 2025
ac6e4db
Shorten line length
pkess Feb 23, 2025
0fcea64
Organize imports
pkess Feb 23, 2025
d37af87
Remove unnecessary else
pkess Feb 23, 2025
6b0378e
Add documentation for new script
pkess Feb 23, 2025
28c80bd
Add handling for -h and help sub command
pkess Feb 23, 2025
c780e8a
Add from none to exception
pkess Feb 23, 2025
de20baf
Fix typo busses to bus
pkess Feb 23, 2025
5a17ef6
Add type annotations
pkess Feb 23, 2025
d81dbab
Fix type annotations
pkess Feb 23, 2025
2e8652f
Fix type annotations again
pkess Feb 23, 2025
3d70761
Add --help to get help
pkess Feb 23, 2025
e883a4e
Add basic print help test
pkess Feb 23, 2025
e32b5d6
Add basic test file for bridge script
pkess Feb 23, 2025
74556a1
Add very basic test
pkess Feb 23, 2025
8a04304
Add different channels for virtual bus
pkess Feb 23, 2025
05f3f03
Add assert for call to exit
pkess Feb 23, 2025
6bfcae9
Patch correct function
pkess Feb 23, 2025
6ffc7d4
test
pkess Feb 24, 2025
036e25c
fjkdf
pkess Feb 24, 2025
e8f03ed
once again -.-
pkess Feb 24, 2025
8df35aa
Try snakecase
pkess Feb 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add very basic test
  • Loading branch information
pkess committed Feb 23, 2025
commit 74556a1717d5e9042147b43039851b5804ab23e8
18 changes: 16 additions & 2 deletions test/test_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This module tests the functions inside of bridge.py
"""

import sys
import unittest
from unittest import mock
from unittest.mock import Mock
Expand All @@ -21,13 +22,26 @@ def setUp(self) -> None:
self.mock_virtual_bus = self.MockVirtualBus.return_value
self.mock_virtual_bus.shutdown = Mock()

# Patch time sleep object
patcher_sleep = mock.patch("can.io.player.time.sleep", spec=True)
self.MockSleep = patcher_sleep.start()
self.addCleanup(patcher_sleep.stop)

self.testmsg = can.Message(
arbitration_id=0xC0FFEE, data=[0, 25, 0, 1, 3, 1, 4, 1], is_extended_id=True
)

self.busargs = ["-i", "virtual"]

def assert_successfull_cleanup(self):
self.MockVirtualBus.assert_called_once()
self.mock_virtual_bus.shutdown.assert_called_once()
self.MockVirtualBus.assert_called()

def test_bridge_no_config(self):
self.MockSleep.side_effect = KeyboardInterrupt
sys.argv = [sys.argv[0], *self.busargs, "--", *self.busargs]
can.bridge.main()

self.assert_successfull_cleanup()


if __name__ == "__main__":
Expand Down