コード例 #1
0
ファイル: test_camera.py プロジェクト: ktavabi/niprov
 def test_Interactive_mode_switched_back_on_even_if_exception_thrown(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.isinteractive.return_value = True
     self.libs.pyplot.subplots.side_effect = ValueError
     camera.takeSnapshot(numpy.zeros([3, 3, 3]), Mock())
     self.libs.pyplot.ion.assert_called_with()
コード例 #2
0
ファイル: test_camera.py プロジェクト: ilogue/niprov
 def test_Interactive_mode_switched_back_on_even_if_exception_thrown(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.isinteractive.return_value = True
     self.libs.pyplot.subplots.side_effect = ValueError
     camera.takeSnapshot(numpy.zeros([3,3,3]), Mock())
     self.libs.pyplot.ion.assert_called_with()
コード例 #3
0
ファイル: test_camera.py プロジェクト: ktavabi/niprov
 def test_SaveSnapshot_doesnt_save_if_takeSnapshot_failed(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     camera.takeSnapshot = Mock()
     camera.takeSnapshot.return_value = False
     target = Mock()
     camera.saveSnapshot(target, for_=sentinel.object)
     self.assertFalse(self.pictureCache.keep.called)
コード例 #4
0
ファイル: test_camera.py プロジェクト: ilogue/niprov
 def test_SaveSnapshot_doesnt_save_if_takeSnapshot_failed(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     camera.takeSnapshot = Mock()
     camera.takeSnapshot.return_value = False
     target = Mock()
     camera.saveSnapshot(target, for_=sentinel.object)
     self.assertFalse(self.pictureCache.keep.called)
コード例 #5
0
ファイル: test_camera.py プロジェクト: ktavabi/niprov
 def test_saveSnapshot(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     camera.takeSnapshot = Mock()
     target = Mock()
     camera.saveSnapshot(target, for_=sentinel.object)
     newPicture = self.pictureCache.new()
     camera.takeSnapshot.assert_called_with(target, on=newPicture)
     self.pictureCache.keep.assert_called_with(newPicture, sentinel.object)
コード例 #6
0
ファイル: test_camera.py プロジェクト: ilogue/niprov
 def test_saveSnapshot(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     camera.takeSnapshot = Mock()
     target = Mock()
     camera.saveSnapshot(target, for_=sentinel.object)
     newPicture = self.pictureCache.new()
     camera.takeSnapshot.assert_called_with(target, on=newPicture)
     self.pictureCache.keep.assert_called_with(newPicture, sentinel.object)
コード例 #7
0
ファイル: test_camera.py プロジェクト: ktavabi/niprov
 def test_If_interactive_mode_is_off_leave_it_off(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.isinteractive.return_value = False
     camera.takeSnapshot(numpy.zeros([3, 3, 3]), Mock())
     assert not self.libs.pyplot.ion.called
コード例 #8
0
ファイル: test_camera.py プロジェクト: ktavabi/niprov
 def test_If_interactive_mode_is_on_temporarily_switches_it_off(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.isinteractive.return_value = True
     camera.takeSnapshot(numpy.zeros([3, 3, 3]), Mock())
     self.libs.pyplot.ioff.assert_called_with()
コード例 #9
0
ファイル: test_camera.py プロジェクト: ktavabi/niprov
 def test_If_no_exception_during_plotting_returns_True(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.subplots.return_value = [Mock(), [Mock()] * 3]
     self.assertTrue(camera.takeSnapshot(numpy.zeros([3, 3, 3]), Mock()))
コード例 #10
0
ファイル: test_camera.py プロジェクト: ktavabi/niprov
 def test_If_exception_during_plotting_returns_False(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.subplots.side_effect = ValueError
     self.assertFalse(camera.takeSnapshot(numpy.zeros([3, 3, 3]), Mock()))
コード例 #11
0
ファイル: test_camera.py プロジェクト: ktavabi/niprov
 def test_If_no_matplotlib_installed_takeSnapshot_returns_false(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.hasDependency.return_value = False
     self.libs.pyplot = None
     self.assertFalse(camera.takeSnapshot(numpy.zeros([3, 3, 3]), Mock()))
コード例 #12
0
ファイル: test_camera.py プロジェクト: ilogue/niprov
 def test_If_interactive_mode_is_off_leave_it_off(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.isinteractive.return_value = False
     camera.takeSnapshot(numpy.zeros([3,3,3]), Mock())
     assert not self.libs.pyplot.ion.called
コード例 #13
0
ファイル: test_camera.py プロジェクト: ilogue/niprov
 def test_If_interactive_mode_is_on_temporarily_switches_it_off(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.isinteractive.return_value = True
     camera.takeSnapshot(numpy.zeros([3,3,3]), Mock())
     self.libs.pyplot.ioff.assert_called_with()
コード例 #14
0
ファイル: test_camera.py プロジェクト: ilogue/niprov
 def test_If_no_exception_during_plotting_returns_True(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.subplots.return_value = [Mock(), [Mock()]*3]
     self.assertTrue(camera.takeSnapshot(numpy.zeros([3,3,3]), Mock()))
コード例 #15
0
ファイル: test_camera.py プロジェクト: ilogue/niprov
 def test_If_exception_during_plotting_returns_False(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.pyplot.subplots.side_effect = ValueError
     self.assertFalse(camera.takeSnapshot(numpy.zeros([3,3,3]), Mock()))
コード例 #16
0
ファイル: test_camera.py プロジェクト: ilogue/niprov
 def test_If_no_matplotlib_installed_takeSnapshot_returns_false(self):
     from niprov.camera import Camera
     camera = Camera(self.dependencies)
     self.libs.hasDependency.return_value = False
     self.libs.pyplot = None
     self.assertFalse(camera.takeSnapshot(numpy.zeros([3,3,3]), Mock()))