test_port.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import pytest
  2. import jack
  3. def test_get_short_name():
  4. client = jack.Client('test')
  5. port = client.register_port(
  6. name = 'port name',
  7. type = jack.DefaultMidiPortType,
  8. direction = jack.Input,
  9. )
  10. assert port.get_short_name() == 'port name'
  11. def test_set_short_name():
  12. client = jack.Client('test')
  13. port = client.register_port(
  14. name = 'port name',
  15. type = jack.DefaultMidiPortType,
  16. direction = jack.Input,
  17. )
  18. port.set_short_name('new port name')
  19. assert port.get_short_name() == 'new port name'
  20. def test_get_client_name():
  21. client = jack.Client('test')
  22. port = client.register_port(
  23. name = 'port name',
  24. type = jack.DefaultMidiPortType,
  25. direction = jack.Input,
  26. )
  27. assert port.get_client_name() == client.get_name()
  28. def test_get_name():
  29. client = jack.Client('test')
  30. port = client.register_port(
  31. name = 'port name',
  32. type = jack.DefaultMidiPortType,
  33. direction = jack.Input,
  34. )
  35. assert port.get_name() == client.get_name() + ':port name'
  36. def test_is_input():
  37. client = jack.Client('test')
  38. port = client.register_port(
  39. name = 'port name',
  40. type = jack.DefaultMidiPortType,
  41. direction = jack.Input,
  42. )
  43. assert port.is_input()
  44. def test_is_not_input():
  45. client = jack.Client('test')
  46. port = client.register_port(
  47. name = 'port name',
  48. type = jack.DefaultMidiPortType,
  49. direction = jack.Output,
  50. )
  51. assert not port.is_input()
  52. def test_is_output():
  53. client = jack.Client('test')
  54. port = client.register_port(
  55. name = 'port name',
  56. type = jack.DefaultMidiPortType,
  57. direction = jack.Output,
  58. )
  59. assert port.is_output()
  60. def test_is_not_output():
  61. client = jack.Client('test')
  62. port = client.register_port(
  63. name = 'port name',
  64. type = jack.DefaultMidiPortType,
  65. direction = jack.Input,
  66. )
  67. assert not port.is_output()
  68. def test_equal():
  69. client = jack.Client('test')
  70. port = client.register_port(
  71. name = 'port name',
  72. type = jack.DefaultMidiPortType,
  73. direction = jack.Input,
  74. )
  75. assert port == [p for p in client.get_ports() if p.get_name() == port.get_name()][0]
  76. def test_unequal():
  77. client = jack.Client('test')
  78. port_a = client.register_port(
  79. name = 'port name a',
  80. type = jack.DefaultMidiPortType,
  81. direction = jack.Input,
  82. )
  83. port_b = client.register_port(
  84. name = 'port name b',
  85. type = jack.DefaultMidiPortType,
  86. direction = jack.Input,
  87. )
  88. assert port_a != port_b