test_client.py 988 B

1234567891011121314151617181920212223242526272829303132333435
  1. import pytest
  2. import jack
  3. import mock
  4. import time
  5. def test_create():
  6. jack.Client('test')
  7. def test_name_conflict():
  8. client = jack.Client('test')
  9. with pytest.raises(jack.Error):
  10. jack.Client(client.get_name(), use_exact_name = True)
  11. def test_register_port():
  12. client = jack.Client('test')
  13. port = client.register_port(
  14. name = 'port name',
  15. type = jack.DefaultMidiPortType,
  16. direction = jack.Input,
  17. )
  18. assert port in client.get_ports()
  19. def test_port_register_callback():
  20. client = jack.Client('test')
  21. port_registered = mock.Mock()
  22. client.set_port_registered_callback(port_registered)
  23. port_unregistered = mock.Mock()
  24. client.set_port_unregistered_callback(port_unregistered)
  25. client.activate()
  26. port = client.register_port('port', jack.DefaultAudioPortType, jack.Output)
  27. time.sleep(0.1)
  28. port_registered.assert_called_with(client, port)
  29. port_unregistered.assert_not_called()