Skip to content

Commit

Permalink
Refactoring detector test
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermef committed Oct 3, 2015
1 parent 564e2f1 commit 030a032
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
21 changes: 21 additions & 0 deletions tests/detectors/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki

# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com timehome@corp.globo.com

from unittest import TestCase
import mock

from thumbor.engines.pil import Engine as PilEngine


class DetectorTestCase(TestCase):
def setUp(self):
self.context = mock.Mock(request=mock.Mock(focal_points=[]))
self.engine = PilEngine(self.context)
self.context.modules.engine = self.engine
11 changes: 2 additions & 9 deletions tests/detectors/test_face_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@
# Copyright (c) 2011 globo.com timehome@corp.globo.com

from os.path import abspath
from unittest import TestCase
import mock

from preggy import expect

from thumbor.detectors.face_detector import Detector as FaceDetector
from thumbor.engines.pil import Engine as PilEngine
from . import DetectorTestCase


class FaceDetectorTestCase(TestCase):
def setUp(self):
self.context = mock.Mock(request=mock.Mock(focal_points=[]))
self.engine = PilEngine(self.context)
self.context.modules.engine = self.engine

class FaceDetectorTestCase(DetectorTestCase):
def test_should_detect_one_face(self):
with open(abspath('./tests/fixtures/images/one_face.jpg')) as f:
self.engine.load(f.read(), None)
Expand Down
11 changes: 2 additions & 9 deletions tests/detectors/test_feature_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@
# Copyright (c) 2011 globo.com timehome@corp.globo.com

from os.path import abspath
from unittest import TestCase
import mock

from preggy import expect
from . import DetectorTestCase

from thumbor.detectors.feature_detector import Detector as FeatureDetector
from thumbor.engines.pil import Engine as PilEngine


class FeatureDetectorTestCase(TestCase):
def setUp(self):
self.context = mock.Mock(request=mock.Mock(focal_points=[]))
self.engine = PilEngine(self.context)
self.context.modules.engine = self.engine

class FeatureDetectorTestCase(DetectorTestCase):
def test_should_detect_multiple_points(self):
with open(abspath('./tests/fixtures/images/no_face.jpg')) as f:
self.engine.load(f.read(), None)
Expand Down

0 comments on commit 030a032

Please sign in to comment.