File: test_console.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 (49 lines) | stat: -rw-r--r-- 1,722 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
38
39
40
41
42
43
44
45
46
47
48
49
# -*- 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 unittest import TestCase

from preggy import expect

from thumbor.console import get_server_parameters


class ConsoleTestCase(TestCase):
    def test_can_get_default_server_parameters(self):
        params = get_server_parameters()
        expect(params.port).to_equal(8888)
        expect(params.ip).to_equal("0.0.0.0")
        expect(params.config_path).to_be_null()
        expect(params.keyfile).to_be_null()
        expect(params.log_level).to_equal("warning")
        expect(params.app_class).to_equal("thumbor.app.ThumborServiceApp")
        expect(params.fd).to_be_null()
        expect(params.processes).to_equal(1)

    def test_can_get_custom_server_parameters(self):
        params = get_server_parameters(
            [
                "--port=9999",
                "--ip=127.0.0.1",
                "--conf=/tmp/conf.conf",
                "--keyfile=./tests/fixtures/thumbor.key",
                "--log-level=debug",
                "--app=custom.app",
                "--fd=/tmp/fd",
                "--processes=5",
            ]
        )
        expect(params.port).to_equal(9999)
        expect(params.ip).to_equal("127.0.0.1")
        expect(params.config_path).to_equal("/tmp/conf.conf")
        expect(params.keyfile).to_equal("./tests/fixtures/thumbor.key")
        expect(params.log_level).to_equal("debug")
        expect(params.app_class).to_equal("custom.app")
        expect(params.fd).to_equal("/tmp/fd")
        expect(params.processes).to_equal(5)