def setUp(self): options = {"url": "http://salvius.org/images/news02.jpg"} connection = Camera(options) # Mock the the image returned by the download method connection.download_image = MagicMock(return_value="tests/news.jpg") self.ocr = OCR(options, connection)
def setUp(self): options = { "url": "http://salvius.org/images/news02.jpg" } connection = Camera(options) # Mock the the image returned by the download method connection.download_image = MagicMock(return_value="tests/news.jpg") self.ocr = OCR(options, connection)
class TestOCR(TestCase): def setUp(self): options = { "url": "http://salvius.org/images/news02.jpg" } connection = Camera(options) # Mock the the image returned by the download method connection.download_image = MagicMock(return_value="tests/news.jpg") self.ocr = OCR(options, connection) def test_ocr(self): text = self.ocr.read() self.assertIn("ROBOT BUILDER from page 1", text) def test_invalid_text(self): """ Test that a string containing no words returns false. """ # Mock the read method to return a non-word string. self.ocr.read = MagicMock( return_value="<()> ~$ %^ H4 fuha9 &&.0 --@-- Qs!" ) text_detected = self.ocr.text_visible() self.assertFalse(text_detected) def test_valid_text(self): """ Test that a string containing words returns true. """ # Mock the read method to return a non-word string. self.ocr.read = MagicMock( return_value="Scientific American volume 307" ) text_detected = self.ocr.text_visible() self.assertTrue(text_detected)
class TestOCR(TestCase): def setUp(self): options = {"url": "http://salvius.org/images/news02.jpg"} connection = Camera(options) # Mock the the image returned by the download method connection.download_image = MagicMock(return_value="tests/news.jpg") self.ocr = OCR(options, connection) def test_ocr(self): text = self.ocr.read() self.assertIn("ROBOT BUILDER from page 1", text) def test_invalid_text(self): """ Test that a string containing no words returns false. """ # Mock the read method to return a non-word string. self.ocr.read = MagicMock( return_value="<()> ~$ %^ H4 fuha9 &&.0 --@-- Qs!") text_detected = self.ocr.text_visible() self.assertFalse(text_detected) def test_valid_text(self): """ Test that a string containing words returns true. """ # Mock the read method to return a non-word string. self.ocr.read = MagicMock( return_value="Scientific American volume 307") text_detected = self.ocr.text_visible() self.assertTrue(text_detected)