text: import unittest.mock as mock
  
  import cv2
  import numpy as np
  
  from apps.rendering.benchmark import renderingbenchmark
  from golem.testutils import TempDirFixture
  
  
  class TestBenchmark(TempDirFixture):
  
      def setUp(self):
          super(self.__class__, self).setUp()
          self.benchmark = renderingbenchmark.RenderingBenchmark()
  
      def test_verify_img(self):
          filepath = self.temp_file_name("img.png")
          resolution = self.benchmark.task_definition.resolution
  
          with open(filepath, "wb"):
              img = np.zeros((resolution[1], resolution[0], 3), np.uint8)
              cv2.imwrite(filepath, img)
              self.assertTrue(self.benchmark.verify_img(filepath))
  
          with open(filepath, "wb"):
              img = np.zeros((resolution[1]+1, resolution[0], 3), np.uint8)
              cv2.imwrite(filepath, img)
              self.assertFalse(self.benchmark.verify_img(filepath))
  
      def test_broken_image(self):
          filepath = self.temp_file_name("broken.png")
          with open(filepath, "w") as f:
              f.write('notanimage,notanimageatall')
          with mock.patch('apps.rendering.benchmark.renderingbenchmark.logger') \
                  as m:
              self.assertFalse(self.benchmark.verify_img(filepath))
              m.exception.assert_called_once()
  
      def test_verify_log(self):
          def verify_log(file_content):
              filepath = self.temp_file_name("log.log")
              fd = open(filepath, "w")
              fd.write(file_content)
              fd.close()
              return self.benchmark.verify_log(filepath)
          for fc in ["Error", "ERROR", "error", "blaErRor", "bla ERRor bla"]:
              self.assertFalse(verify_log(fc))
          for fc in ["123", "erro r", "asd sda", "sad 12 sad;"]:
              self.assertTrue(verify_log(fc))
  
      def test_verify_result(self):
          """Wether verify_result calls correct methods."""
  
          with mock.patch.multiple(self.benchmark, verify_img=mock.DEFAULT,
                                   verify_log=mock.DEFAULT) as mocks:
              self.assertTrue(self.benchmark.verify_result(['a.txt', 'b.gif']))
              self.assertEqual(mocks['verify_img'].call_count, 0)
              self.assertEqual(mocks['verify_log'].call_count, 0)
  
              for m in mocks.values():
                  m.return_value = True
              paths = [
                  '/mnt/dummy/image.png',
                  '../important.log',
              ]
              self.assertTrue(self.benchmark.verify_result(paths))
              mocks['verify_img'].assert_called_once_with(paths[0])
              mocks['verify_log'].assert_called_once_with(paths[1])
  
              for m in mocks.values():
                  m.reset_mock()
                  m.return_value = False
  
              self.assertFalse(self.benchmark.verify_result([paths[0]]))
              self.assertFalse(self.benchmark.verify_result([paths[1]]))
              mocks['verify_img'].assert_called_once_with(paths[0])
              mocks['verify_log'].assert_called_once_with(paths[1])
  
      def test_find_resources(self):
          """Simplistic test of basic implementation."""
          self.assertEqual(self.benchmark.find_resources(), set())
  