Skip to content

Commit

Permalink
Remove mock library dependency (thumbor#1396)
Browse files Browse the repository at this point in the history
  • Loading branch information
jairhenrique authored Jan 25, 2022
1 parent 86fef3d commit a8c789e
Show file tree
Hide file tree
Showing 34 changed files with 53 additions and 66 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"coverage==5.*,>=5.0.3",
"flake8==3.*,>=3.7.9",
"isort==4.*,>=4.3.21",
"mock==3.*,>=3.0.5",
"numpy==1.*,>=1.18.1",
"preggy==1.*,>=1.4.4",
"py3exiv2==0.*,>=0.7.1,!=0.7.2,!=0.8.0,!=0.9.3",
Expand Down
2 changes: 1 addition & 1 deletion tests/detectors/test_glasses_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Copyright (c) 2011 globo.com [email protected]

from os.path import abspath
from unittest import mock

import mock
from preggy import expect
from tornado.testing import gen_test

Expand Down
2 changes: 1 addition & 1 deletion tests/detectors/test_profile_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Copyright (c) 2011 globo.com [email protected]

from os.path import abspath
from unittest import mock

import mock
from preggy import expect
from tornado.testing import gen_test

Expand Down
2 changes: 1 addition & 1 deletion tests/detectors/test_queued_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Copyright (c) 2011 globo.com [email protected]

from json import loads
from unittest import mock

import mock
from preggy import expect
from redis import Redis
from tornado.testing import gen_test
Expand Down
3 changes: 1 addition & 2 deletions tests/engines/test_base_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@

from os.path import abspath, dirname, join
from struct import pack
from unittest import TestCase
from unittest import TestCase, mock
from xml.etree.ElementTree import ParseError

import mock
from preggy import expect

from thumbor.config import Config
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_base_handler_respecting_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from preggy import expect
from tornado.testing import gen_test

from tests.handlers.test_base_handler import BaseImagingTestCase
from thumbor.config import Config
from thumbor.context import Context, ServerParameters
from thumbor.engines.pil import Engine
from thumbor.importer import Importer
from tests.handlers.test_base_handler import BaseImagingTestCase

# pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods
# pylint: disable=too-many-lines
Expand Down
5 changes: 3 additions & 2 deletions tests/handlers/test_base_handler_with_auto_png_to_jpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com [email protected]

from mock import patch
from unittest.mock import patch

from libthumbor import CryptoURL
from preggy import expect
from tornado.testing import gen_test

from tests.handlers.test_base_handler import BaseImagingTestCase
from thumbor.config import Config
from thumbor.context import RequestParameters, ServerParameters
from thumbor.importer import Importer
from tests.handlers.test_base_handler import BaseImagingTestCase

# pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods
# pylint: disable=too-many-lines
Expand Down
6 changes: 3 additions & 3 deletions tests/handlers/test_base_handler_with_auto_webp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
# Copyright (c) 2011 globo.com [email protected]

from shutil import which
from unittest.mock import patch
from urllib.parse import quote

from libthumbor import CryptoURL
from preggy import expect
from tornado.testing import gen_test
from mock import patch
from libthumbor import CryptoURL

from tests.handlers.test_base_handler import BaseImagingTestCase
from thumbor.config import Config
from thumbor.context import Context, RequestParameters, ServerParameters
from thumbor.importer import Importer
from tests.handlers.test_base_handler import BaseImagingTestCase

# pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods
# pylint: disable=too-many-lines
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_base_handler_with_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from preggy import expect
from tornado.testing import gen_test

from tests.handlers.test_base_handler import BaseImagingTestCase
from thumbor.config import Config
from thumbor.context import Context, ServerParameters
from thumbor.importer import Importer
from tests.handlers.test_base_handler import BaseImagingTestCase

# pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods
# pylint: disable=too-many-lines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from preggy import expect
from tornado.testing import gen_test

from tests.handlers.test_base_handler import BaseImagingTestCase
from thumbor.config import Config
from thumbor.context import Context, ServerParameters
from thumbor.engines.pil import Engine
from thumbor.importer import Importer
from thumbor.storages.file_storage import Storage as FileStorage
from thumbor.storages.no_storage import Storage as NoStorage
from tests.handlers.test_base_handler import BaseImagingTestCase

# pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods
# pylint: disable=too-many-lines
Expand Down
5 changes: 3 additions & 2 deletions tests/handlers/test_base_handler_with_engine_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com [email protected]

from unittest.mock import patch

import pytest
from mock import patch
from preggy import expect
from tornado.testing import gen_test

from tests.handlers.test_base_handler import BaseImagingTestCase
from thumbor.config import Config
from thumbor.context import Context, ServerParameters
from thumbor.engines.pil import Engine
from thumbor.importer import Importer
from tests.handlers.test_base_handler import BaseImagingTestCase

# pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods
# pylint: disable=too-many-lines
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_base_handler_with_gifv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from preggy import expect
from tornado.testing import gen_test

from tests.handlers.test_base_handler import BaseImagingTestCase
from thumbor.config import Config
from thumbor.context import Context, ServerParameters
from thumbor.importer import Importer
from tests.handlers.test_base_handler import BaseImagingTestCase

# pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods
# pylint: disable=too-many-lines
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/test_base_handler_with_http_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def test_can_get_image_cors_header(self):

class ImageOperationsWithCorsHeaderTestCase(BaseImagingTestCase):
def get_context(self):
cfg = Config(SECURITY_KEY="ACME-SEC", ACCESS_CONTROL_ALLOW_ORIGIN_HEADER='*')
cfg = Config(SECURITY_KEY="ACME-SEC", ACCESS_CONTROL_ALLOW_ORIGIN_HEADER="*")
cfg.LOADER = "thumbor.loaders.file_loader"
cfg.FILE_LOADER_ROOT_PATH = self.loader_path
cfg.ENABLE_ETAGS = False
Expand All @@ -93,7 +93,7 @@ async def test_can_get_image_with_cors_header(self):

expect(response.code).to_equal(200)
expect(response.headers).to_include("Access-Control-Allow-Origin")
expect(response.headers['Access-Control-Allow-Origin']).to_equal('*')
expect(response.headers["Access-Control-Allow-Origin"]).to_equal("*")


class ImageOperationsWithLastModifiedTestCase(BaseImagingTestCase):
Expand Down
10 changes: 5 additions & 5 deletions tests/handlers/test_base_handler_with_jpegtran.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
from preggy import expect
from tornado.testing import gen_test

from thumbor.config import Config
from thumbor.context import Context, ServerParameters
from thumbor.importer import Importer
from tests.handlers.test_base_handler import (
BaseImagingTestCase,
JPEGTRAN_AVAILABLE,
EXIFTOOL_AVAILABLE,
JPEGTRAN_AVAILABLE,
BaseImagingTestCase,
)
from thumbor.config import Config
from thumbor.context import Context, ServerParameters
from thumbor.importer import Importer

# pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods
# pylint: disable=too-many-lines
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_base_handler_with_loader_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from preggy import expect
from tornado.testing import gen_test

from tests.handlers.test_base_handler import BaseImagingTestCase
from thumbor.config import Config
from thumbor.context import Context, ServerParameters
from thumbor.importer import Importer
from thumbor.loaders import LoaderResult
from tests.handlers.test_base_handler import BaseImagingTestCase

# pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods
# pylint: disable=too-many-lines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import os
from os.path import dirname
from unittest.mock import Mock

from mock import Mock
from preggy import expect
from tornado.testing import gen_test

Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_base_handler_with_result_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import os
from os.path import dirname
from shutil import which
from unittest.mock import Mock, patch

from mock import Mock, patch
from preggy import expect
from tornado.testing import gen_test

Expand Down
3 changes: 2 additions & 1 deletion tests/handlers/test_fetch_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com [email protected]

from mock import Mock
from unittest.mock import Mock

from preggy import expect

from tests.base import TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/loaders/test_file_loader_http_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Copyright (c) 2011 globo.com [email protected]

from os.path import abspath, dirname, join
from unittest.mock import patch

from mock import patch
from preggy import expect
from tornado.testing import gen_test

Expand Down
6 changes: 3 additions & 3 deletions tests/metrics/test_default_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com [email protected]

import mock
from unittest import mock

from preggy import expect

import thumbor.metrics
from thumbor.importer import Importer

from tests.base import TestCase
from thumbor.importer import Importer


class DefaultMetricsTestCase(TestCase):
Expand Down
7 changes: 3 additions & 4 deletions tests/metrics/test_logger_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

from preggy import expect

from thumbor.context import Context
from thumbor.importer import Importer
from thumbor.config import Config
import thumbor.metrics

from tests.base import TestCase
from thumbor.config import Config
from thumbor.context import Context
from thumbor.importer import Importer


class LoggerMetricsTestCase(TestCase):
Expand Down
7 changes: 3 additions & 4 deletions tests/metrics/test_statsd_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

from preggy import expect

from thumbor.context import Context
from thumbor.importer import Importer
from thumbor.config import Config
import thumbor.metrics

from tests.base import TestCase
from thumbor.config import Config
from thumbor.context import Context
from thumbor.importer import Importer


class StatsdMetricsTestCase(TestCase):
Expand Down
4 changes: 1 addition & 3 deletions tests/optimizers/test_gifv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
# Copyright (c) 2011 globo.com [email protected]

from shutil import which
from unittest import TestCase

import mock
from unittest import TestCase, mock

from thumbor.config import Config
from thumbor.context import Context, RequestParameters
Expand Down
4 changes: 1 addition & 3 deletions tests/optimizers/test_jpegtran.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com [email protected]

from unittest import TestCase

import mock
from unittest import TestCase, mock

from thumbor.config import Config
from thumbor.context import Context, RequestParameters
Expand Down
2 changes: 1 addition & 1 deletion tests/result_storages/test_file_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import tempfile
from datetime import datetime
from os.path import abspath, dirname, join
from unittest import mock

import mock
from preggy import expect
from tornado.testing import gen_test

Expand Down
2 changes: 1 addition & 1 deletion tests/storages/test_file_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from datetime import datetime
from os.path import dirname, exists, join
from tempfile import mkdtemp
from unittest import mock

import mock
from preggy import expect
from tornado.testing import gen_test

Expand Down
5 changes: 2 additions & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
# Copyright (c) 2011 globo.com [email protected]

from os.path import expanduser
from unittest import TestCase
import mock
from unittest import TestCase, mock

from preggy import expect

from thumbor.config import generate_config, format_value, Config
from thumbor.config import Config, format_value, generate_config


class ConfigTestCase(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com [email protected]

from unittest import TestCase
from unittest import TestCase, mock

import mock
from preggy import expect

from thumbor.config import Config
Expand Down
3 changes: 1 addition & 2 deletions tests/test_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

from preggy import expect

from thumbor.point import FocalPoint

from tests.base import TestCase
from thumbor.point import FocalPoint


class FocalPointTestCase(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com [email protected]

from unittest import TestCase
from unittest import TestCase, mock

import mock
from preggy import expect

import thumbor.server
Expand Down
Loading

0 comments on commit a8c789e

Please sign in to comment.