本文整理汇总了Python中mock.MagicMock.seqno方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.seqno方法的具体用法?Python MagicMock.seqno怎么用?Python MagicMock.seqno使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.seqno方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_handler_stale_seqno
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_handler_stale_seqno():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
with patch.object(compoundpi.server.warnings, 'warn') as w:
socket = Mock()
server = MagicMock()
server.seqno = 10
server.client_address = ('localhost', 1)
compoundpi.server.CameraRequestHandler(
(b'0 LIST', socket), ('localhost', 1), server)
assert w.call_count == 1
assert isinstance(
w.call_args[0][0], compoundpi.exc.CompoundPiStaleSequence)
示例2: test_iso_handler
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_iso_handler():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
handler = compoundpi.server.CameraRequestHandler(
(b'2 ISO 400', socket), ('localhost', 1), server)
assert server.seqno == 2
assert server.camera.iso == 400
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n')
示例3: test_metering_handler
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_metering_handler():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
handler = compoundpi.server.CameraRequestHandler(
(b'2 METERING spot', socket), ('localhost', 1), server)
assert server.seqno == 2
assert server.camera.meter_mode == 'spot'
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n')
示例4: test_awb_handler_auto
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_awb_handler_auto():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
handler = compoundpi.server.CameraRequestHandler(
(b'2 AWB auto 1.0 1.0', socket), ('localhost', 1), server)
assert server.seqno == 2
assert server.camera.awb_mode == 'auto'
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n')
示例5: test_resolution_handler
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_resolution_handler():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
handler = compoundpi.server.CameraRequestHandler(
(b'2 RESOLUTION 1920 1080', socket), ('localhost', 1), server)
assert server.seqno == 2
assert server.camera.resolution == (1920, 1080)
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n')
示例6: test_blink_handler
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_blink_handler():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
with patch('threading.Thread') as thread:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 0
handler = compoundpi.server.CameraRequestHandler(
(b'1 BLINK', socket), ('localhost', 1), server)
assert server.seqno == 1
m.assert_called_once_with(
socket, ('localhost', 1), '1 OK\n')
thread.assert_called_once_with(target=handler.blink_led, args=(5,))
示例7: test_flip_handler
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_flip_handler():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
handler = compoundpi.server.CameraRequestHandler(
(b'2 FLIP 1 0', socket), ('localhost', 1), server)
assert server.seqno == 2
assert server.camera.hflip == True
assert server.camera.vflip == False
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n')
示例8: test_awb_handler_manual
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_awb_handler_manual():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
handler = compoundpi.server.CameraRequestHandler(
(b'2 AWB off 1.5 1.3', socket), ('localhost', 1), server)
assert server.seqno == 2
assert server.camera.awb_mode == 'off'
assert server.camera.awb_gains == (1.5, 1.3)
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n')
示例9: test_levels_handler
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_levels_handler():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
handler = compoundpi.server.CameraRequestHandler(
(b'2 LEVELS 1 2 3', socket), ('localhost', 1), server)
assert server.seqno == 2
assert server.camera.brightness == 1
assert server.camera.contrast == 2
assert server.camera.saturation == 3
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n')
示例10: test_exposure_handler
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_exposure_handler():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
handler = compoundpi.server.CameraRequestHandler(
(b'2 EXPOSURE auto 20.0 24', socket), ('localhost', 1), server)
assert server.seqno == 2
assert server.camera.exposure_mode == 'auto'
assert server.camera.shutter_speed == 20000.0
assert server.camera.exposure_compensation == 24
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n')
示例11: test_capture_handler_past_sync
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_capture_handler_past_sync():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
with patch.object(compoundpi.server.time, 'time') as now:
with patch.object(compoundpi.server.time, 'sleep') as sleep:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
now.return_value = 1000.0
with patch.object(compoundpi.server.CameraRequestHandler, 'stream_generator') as gen:
handler = compoundpi.server.CameraRequestHandler(
(b'2 CAPTURE 1 0 900.0', socket), ('localhost', 1), server)
assert m.call_count == 1
args, kwargs = m.call_args
assert args[0] == socket
assert args[1] == ('localhost', 1)
assert args[2].startswith('2 ERROR\n')
示例12: test_capture_handler
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_capture_handler():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
with patch.object(compoundpi.server.CameraRequestHandler, 'stream_generator') as gen:
gen.return_value = sentinel.iterator
handler = compoundpi.server.CameraRequestHandler(
(b'2 CAPTURE 1 1', socket), ('localhost', 1), server)
assert server.seqno == 2
assert server.camera.led == True
server.camera.capture_sequence.assert_called_once_with(
sentinel.iterator, format='jpeg', use_video_port=True)
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n')
示例13: test_status_handler
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import seqno [as 别名]
def test_status_handler():
with patch.object(compoundpi.server, 'NetworkRepeater') as m:
with patch.object(compoundpi.server.time, 'time') as now:
socket = Mock()
server = MagicMock()
server.client_address = ('localhost', 1)
server.seqno = 1
server.camera.resolution = (1280, 720)
server.camera.framerate = 30
server.camera.awb_mode = 'auto'
server.camera.awb_gains = (1.5, 1.3)
server.camera.exposure_mode = 'off'
server.camera.exposure_speed = 100000
server.camera.exposure_compensation = 0
server.camera.iso = 100
server.camera.meter_mode = 'spot'
server.camera.brightness = 50
server.camera.contrast = 25
server.camera.saturation = 15
server.camera.hflip = True
server.camera.vflip = False
server.images = []
now.return_value = 2000.0
handler = compoundpi.server.CameraRequestHandler(
(b'2 STATUS', socket), ('localhost', 1), server)
assert server.seqno == 2
m.assert_called_once_with(
socket, ('localhost', 1),
'2 OK\n'
'RESOLUTION 1280 720\n'
'FRAMERATE 30\n'
'AWB auto 1.5 1.3\n'
'EXPOSURE off 100.0 0\n'
'ISO 100\n'
'METERING spot\n'
'LEVELS 50 25 15\n'
'FLIP 1 0\n'
'TIMESTAMP 2000.0\n'
'IMAGES 0\n')