File: test_simple_compatibility.py

package info (click to toggle)
thumbor 7.7.7-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 40,556 kB
  • sloc: xml: 295,435; python: 18,673; ansic: 1,479; makefile: 360; sh: 27
file content (37 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- 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 thumbor@googlegroups.com

from preggy import expect
from tornado.testing import gen_test

from tests.base import TestCase
from thumbor.compatibility import compatibility_get


def get_result(first, second, callback):
    callback(first, second, True)


class SimpleCompatibilityTestCase(TestCase):
    @gen_test
    async def test_can_get_result(self):
        first, second, response = await compatibility_get(
            1, second=2, func=get_result
        )
        expect(first).to_equal(1)
        expect(second).to_equal(2)
        expect(response).to_be_true()

    @gen_test
    async def test_fails_without_func(self):
        with expect.error_to_happen(
            RuntimeError,
            message="'func' argument can't be None when calling thumbor's compatibility layer.",
        ):
            await compatibility_get(1, second=2)