-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6fd794
commit bad57d0
Showing
1 changed file
with
69 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# coding=utf-8 | ||
|
||
"""scikit-surgerynditracker tests using a mocked ndicapy""" | ||
import ndicapy | ||
from mock import call | ||
from sksurgerynditracker.nditracker import NDITracker | ||
|
||
SETTINGS_VEGA = { | ||
"tracker type": "vega", | ||
"ip address" : "127.0.0.1", | ||
"port" : 0000, | ||
"romfiles" : [ | ||
"data/something_else.rom", | ||
"data/8700339.rom"] | ||
} | ||
|
||
def mockndiOpenNetwork(_ip_address, _port): #pylint:disable=invalid-name | ||
"""Mock of ndiOpenNetwork""" | ||
return True | ||
|
||
def mockndiGetError(_device): #pylint:disable=invalid-name | ||
"""Mock of ndiGetError""" | ||
return ndicapy.NDI_OKAY | ||
|
||
def mockndiGetPHSRNumberOfHandles(_device): #pylint:disable=invalid-name | ||
"""Mock of ndiGetPHSRNumberOfHandles""" | ||
return 0 | ||
|
||
def mockndiGetPHRQHandle(_device, index=0): #pylint:disable=invalid-name | ||
"""Mock of ndiGetPHRQHandle""" | ||
return int(index) | ||
|
||
def mockndiGetPHSRHandle(_device, index): #pylint:disable=invalid-name | ||
"""Mock of ndiGetPHSRHandle""" | ||
return int(index) | ||
|
||
def mockndiVER(_device, _other_arg): #pylint:disable=invalid-name | ||
"""Mock of ndiVER""" | ||
return 'Mock for Testing' | ||
|
||
def test_connect_vega_mock(mocker): | ||
""" | ||
connects and configures, mocks ndicapy.ndiProbe to pass | ||
reqs: 03, 04 | ||
""" | ||
tracker = None | ||
mocker.patch('ndicapy.ndiOpenNetwork', mockndiOpenNetwork) | ||
mocker.patch('ndicapy.ndiCommand') | ||
mocker.patch('ndicapy.ndiGetError', mockndiGetError) | ||
mocker.patch('ndicapy.ndiClose') | ||
mocker.patch('ndicapy.ndiGetPHSRNumberOfHandles', | ||
mockndiGetPHSRNumberOfHandles) | ||
mocker.patch('ndicapy.ndiGetPHRQHandle', mockndiGetPHRQHandle) | ||
mocker.patch('ndicapy.ndiPVWRFromFile') | ||
mocker.patch('ndicapy.ndiGetPHSRHandle', mockndiGetPHSRHandle) | ||
mocker.patch('ndicapy.ndiVER', mockndiVER) | ||
spy = mocker.spy(ndicapy, 'ndiCommand') | ||
tracker = NDITracker(SETTINGS_VEGA) | ||
|
||
assert spy.call_count == 9 | ||
assert spy.call_args_list[0] == call(True, 'INIT:') | ||
assert spy.call_args_list[1] == call(True, 'PHSR:01') | ||
assert spy.call_args_list[3] == call(True, 'PHRQ:*********1****') | ||
assert spy.call_args_list[4] == call(True, 'PHSR:01') | ||
assert spy.call_args_list[5] == call(True, 'PHSR:02') | ||
assert spy.call_args_list[6] == call(True, 'PINIT:00') | ||
assert spy.call_args_list[7] == call(True, 'PINIT:00') | ||
assert spy.call_args_list[8] == call(True, 'PHSR:03') | ||
del tracker |