Esempio n. 1
0
 def test_get_options_fails_when_no_url(self, mock_stdout):
     get_options([
         '-k', 'MY-SECURITY-KEY',
         '-w', '200',
         '-e', '300',
     ])
     expect(mock_stdout.getvalue()).to_equal(
         'Error: The image argument is mandatory. For more information type thumbor-url -h\n'
     )
Esempio n. 2
0
 def test_get_options_fails_when_no_url(self, mock_stdout):
     get_options([
         '-k', 'MY-SECURITY-KEY',
         '-w', '200',
         '-e', '300',
     ])
     expect(mock_stdout.getvalue()).to_equal(
         'Error: The image argument is mandatory. For more information type thumbor-url -h\n'
     )
Esempio n. 3
0
    def test_get_options(self):
        options, args = get_options([
            '-k', 'MY-SECURITY-KEY', '-w', '200', '-e', '300',
            'myserver.com/myimg.jpg'
        ])

        expect(options.key).to_equal('MY-SECURITY-KEY')
        expect(options.width).to_equal(200)
        expect(options.height).to_equal(300)

        expect(args).to_length(1)
        expect(args[0]).to_equal('myserver.com/myimg.jpg')
Esempio n. 4
0
    def test_get_options(self):
        options, args = get_options([
            '-k', 'MY-SECURITY-KEY',
            '-w', '200',
            '-e', '300',
            'myserver.com/myimg.jpg'
        ])

        expect(options.key).to_equal('MY-SECURITY-KEY')
        expect(options.width).to_equal(200)
        expect(options.height).to_equal(300)

        expect(args).to_length(1)
        expect(args[0]).to_equal('myserver.com/myimg.jpg')
Esempio n. 5
0
    def test_get_options_from_sys(self):
        argv = [
            'thumbor-url', '-k', 'MY-SECURITY-KEY', '-w', '200', '-e', '300',
            'myserver.com/myimg.jpg'
        ]
        with mock.patch.object(sys, 'argv', argv):
            options, args = get_options(None)

        expect(options.key).to_equal('MY-SECURITY-KEY')
        expect(options.width).to_equal(200)
        expect(options.height).to_equal(300)

        expect(args).to_length(1)
        expect(args[0]).to_equal('myserver.com/myimg.jpg')
Esempio n. 6
0
    def test_get_options(self):
        options, args = get_options([
            "-k",
            "MY-SECURITY-KEY",
            "-w",
            "200",
            "-e",
            "300",
            "myserver.com/myimg.jpg",
        ])

        expect(options.key).to_equal("MY-SECURITY-KEY")
        expect(options.width).to_equal(200)
        expect(options.height).to_equal(300)

        expect(args).to_length(1)
        expect(args[0]).to_equal("myserver.com/myimg.jpg")
Esempio n. 7
0
    def test_get_options_from_sys(self):
        argv = [
            'thumbor-url',
            '-k', 'MY-SECURITY-KEY',
            '-w', '200',
            '-e', '300',
            'myserver.com/myimg.jpg'
        ]
        with mock.patch.object(sys, 'argv', argv):
            options, args = get_options(None)

        expect(options.key).to_equal('MY-SECURITY-KEY')
        expect(options.width).to_equal(200)
        expect(options.height).to_equal(300)

        expect(args).to_length(1)
        expect(args[0]).to_equal('myserver.com/myimg.jpg')
Esempio n. 8
0
    def test_get_options_from_sys(self):
        argv = [
            "thumbor-url",
            "-k",
            "MY-SECURITY-KEY",
            "-w",
            "200",
            "-e",
            "300",
            "myserver.com/myimg.jpg",
        ]
        with mock.patch.object(sys, "argv", argv):
            options, args = get_options(None)

        expect(options.key).to_equal("MY-SECURITY-KEY")
        expect(options.width).to_equal(200)
        expect(options.height).to_equal(300)

        expect(args).to_length(1)
        expect(args[0]).to_equal("myserver.com/myimg.jpg")
Esempio n. 9
0
 def test_get_options_fails_when_no_url(self):
     parsed_options, arguments = get_options(
         ["-k", "MY-SECURITY-KEY", "-w", "200", "-e", "300"])
     expect(parsed_options).to_be_null()
     expect(arguments).to_be_null()