# -*- encoding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2015 Compassion CH (http://www.compassion.ch)
#    Releasing children from poverty in Jesus' name
#    @author: Emanuel Cino <ecino@compassion.ch>
#
#    The licence is in the file __openerp__.py
#
##############################################################################

import unittest

import logging
import cv2
import os
from tools import bluecornerfinder as bcf

logger = logging.getLogger(__name__)
THIS_DIR = os.path.dirname(__file__)


class TestImportLetter(unittest.TestCase):
    """
    TODO doc
    """

    def setUp(self):
        self.test_document_normal = os.path.join(THIS_DIR,
                                                 'testdata/normal.png')

    def test_blue_corner_finder(self):
        """TODO doc"""
        img = cv2.imread(self.test_document_normal)
        self.assertIsNotNone(img)
        bluecorner = bcf.BlueCornerFinder(img)
        bluecorner_position = bluecorner.getIndices()
        self.assertEqual(bluecorner_position, [2438, 76])

@@ -414,16 +414,30 @@
 ittest%0A%0A
+import tools%0A%0A
 import l
@@ -467,50 +467,8 @@
 t os
-%0Afrom tools import bluecornerfinder as bcf
 %0A%0Alo
@@ -798,16 +798,28 @@
 r_finder
+_should_find
 (self):%0A
@@ -829,24 +829,65 @@
      %22%22%22
-TODO doc
+Blue corner should be found at known coordinates.
 %22%22%22%0A    
@@ -900,18 +900,22 @@
 g = 
-cv2.imread
+self._read_img
 (sel
@@ -950,42 +950,27 @@
     
-self.assertIsNotNone(img)%0A        
+bluecorner = tools.
 blue
@@ -979,14 +979,14 @@
 rner
- = bcf
+finder
 .Blu
@@ -1116,8 +1116,960 @@
 8, 76%5D)%0A
+        # TODO add tests with more documents%0A%0A    def test_blue_corner_finder_should_not_find(self):%0A        %22%22%22Blue corner should not be found.%22%22%22%0A%0A    def test_pattern_recognition(self):%0A        %22%22%22TODO doc%22%22%22%0A        # TODO: need image files or base64 representation of patterns to test%0A%0A    def test_zxing_read_qr_code(self):%0A        %22%22%22QR code should be read correctly.%22%22%22%0A        bar_code_tool = tools.zxing.BarCodeTool()%0A        path = os.path.abspath(self.test_document_normal)%0A        qr_code = bar_code_tool.decode(path,%0A                                       try_harder=True)%0A        self.assertEqual(qr_code.data, %221509540XXGU4920269%5Cn%22)%0A        # TODO add tests with more documents%0A%0A    def test_zxing_no_qr_code(self):%0A        %22%22%22Should report error for document that does not contain QR code.%22%22%22%0A        # TODO implement%0A%0A    def _read_img(self, path):%0A        img = cv2.imread(path)%0A        self.assertIsNotNone(img)%0A        return img%0A

add a test for QR code reader; add TODOs