#!/usr/bin/python

import unittest
import monitor

class TestMonitor(unittest.TestCase):

	def test_attr(self):
		mon = monitor.Monitor()
		assert mon.pvprefix == "MON-CONTROL:"
		assert mon.monitorname == "PI1"

	def test_testimage(self):
		mon = monitor.Monitor()
		image = mon.testimage()
		assert len(image) != 0
#		print image

	def test_readPV(self):
		mon = monitor.Monitor()
		pv_result = mon.readPV()
		assert pv_result == "CAM1"


if __name__ == '__main__':
	unittest.main()

@@ -32,30 +32,93 @@
 est%0A
-import monitor
+from mock import patch, MagicMock, PropertyMock%0A%0Afrom monitor import Monitor%0A
 %0A%0Aclass 
 Test
@@ -117,19 +117,25 @@
 ass 
-Test
 Monitor
+UpdateTest
 (uni
@@ -156,54 +156,140 @@
 ):%0A%0A
-%09def test_attr(self):%0A%09%09mon = 
+    def setUp(self):%0A        with patch('monitor.pv.PV'):%0A            mock_plotter = MagicMock()%0A            self.
 monitor
-.
+ = 
 Monitor(
 )%0A%09%09
@@ -288,70 +288,421 @@
 tor(
-)%0A%09%09assert mon.pvprefix == %22MON-CONTROL:%22%0A%09%09assert mon
+%22MYNAME%22, mock_plotter)%0A%0A    def test_does_nothing_if_camera_is_None(self):%0A        self.monitor.camera = None%0A%0A        try:%0A            self.monitor._update_image()%0A            self.assertTrue(True)%0A        except Exception as ex:%0A            self.fail(%22Unexpected expection thrown%22 + str(ex))%0A%0A%0A    def test_gets_image_data_from_camera_when_not_None(self):%0A        mock_camera = MagicMock()%0A        self
 .monitor
 name
@@ -701,248 +701,993 @@
 itor
-name == %22PI1%22%0A%0A%09def test_testimage(self):%0A%09%09mon = monitor.Monitor()%0A%09%09image = mon.testimage()%0A%09%09assert len(image) != 0%0A#%09%09print image%0A%0A%09def test_readPV(self):%0A%09%09mon = monitor.Monitor()%0A%09%09pv_result = mon.readPV()%0A%09%09assert pv_result == %22CAM1%22
+.camera = mock_camera%0A%0A        self.monitor._update_image()%0A%0A        mock_camera.get_image_data.assert_called_once_with()%0A%0A    def test_get_size_data_from_camera_when_not_None(self):%0A        mock_camera = MagicMock()%0A%0A        mock_xsize = PropertyMock(return_value=100)%0A        mock_ysize = PropertyMock(return_value=200)%0A        type(mock_camera).xsize = mock_xsize%0A        type(mock_camera).ysize = mock_ysize%0A%0A        self.monitor.camera = mock_camera%0A%0A        self.monitor._update_image()%0A%0A        mock_xsize.assert_called_once_with()%0A        mock_ysize.assert_called_once_with()%0A%0A    def test_calls_plotter_with_image_and_size_data(self):%0A        data = 111%0A        xsize = 100%0A        ysize = 200%0A        mock_camera = MagicMock(xsize=xsize, ysize=ysize)%0A        mock_camera.get_image_data = MagicMock(return_value=data)%0A        self.monitor.camera = mock_camera%0A%0A        self.monitor._update_image()%0A%0A        self.monitor.plotter.show.assert_called_once_with(data, xsize, ysize)
 %0A%0A%0Ai
@@ -1716,9 +1716,12 @@
 _':%0A
-%09
+    
 unit

Rewrite monitortests. Add tests for update_image