Пример #1
0
    def it_returns_an_image_otherwise(mock_send_file):

        display("my_title", "my_path")

        expect(mock_send_file.mock_calls) == [
            call("my_path", mimetype='image/jpeg'),
        ]
Пример #2
0
    def it_returns_an_image_otherwise(mock_send_file, app):
        with app.test_request_context():
            display("my_title", "my_path")

        expect(mock_send_file.mock_calls) == [
            call("my_path", mimetype='image/jpeg'),
        ]
Пример #3
0
    def it_returns_an_image_otherwise(mock_send_file, app):
        with app.test_request_context():
            display("my_title", "my_path")

        expect(mock_send_file.mock_calls) == [
            call("my_path", mimetype='image/jpeg'),
        ]
Пример #4
0
    def it_returns_html_when_sharing(app):
        with app.test_request_context():
            html = display("my_title", "my_path", share=True, raw=True)

        print(html)
        assert "<title>my_title</title>" in html
        assert 'src="it\'s a path?alt=style"' in html
        assert "ga('create', 'my_tid', 'auto');" in html
Пример #5
0
    def it_returns_html_when_sharing(app):
        with app.test_request_context():
            html = display("my_title", "my_path", share=True, raw=True)

        print(html)
        assert "<title>my_title</title>" in html
        assert 'src="it\'s a path?alt=style"' in html
        assert "ga('create', 'my_tid', 'auto');" in html
Пример #6
0
    def it_returns_html_for_browsers(app):
        with app.test_request_context():
            html = display("my_title", "my_path", raw=True)

        print(html)
        assert "<title>my_title</title>" in html
        assert 'url("http://foo.com?alt=http://bar.com/qux.jpg")' in html
        assert "ga('create', 'my_tid', 'auto');" in html
Пример #7
0
    def it_returns_html_for_browsers(app):

        with app.test_request_context():
            html = display("my_title", "my_path", raw=True)

        print(html)
        assert "<title>my_title</title>" in html
        assert 'url("it\'s a path?alt=style")' in html
        assert "ga('create', 'my_tid', 'auto');" in html
Пример #8
0
    def it_forces_https_in_production(app):
        app.config['ENV'] = 'prod'
        with app.test_request_context():
            html = display("my_title", "my_path", raw=True)

        print(html)
        assert "<title>my_title</title>" in html
        assert 'url("https://foo.com?alt=http://bar.com/qux.jpg")' in html
        assert "ga('create', 'my_tid', 'auto');" in html
Пример #9
0
    def it_returns_html_for_browsers(app):

        with app.test_request_context():
            html = display("my_title", "my_path", raw=True)

        print(html)
        assert "<title>my_title</title>" in html
        assert 'url("it\'s a path?alt=style")' in html
        assert "ga('create', 'my_tid', 'auto');" in html
Пример #10
0
    def it_returns_html_when_sharing(app):
        with app.test_request_context():
            request_share.args = {'alt': 'foobar', 'share': ['true']}
            html = display("my_title", "my_path", share=True, raw=True)

        print(html)
        assert "<title>my_title</title>" in html
        assert 'src="it\'s a path?alt=foobar"' in html
        assert 'return "it\'s a path?alt=foobar&share=true"' in html
        assert "ga('create', 'my_tid', 'auto');" in html
Пример #11
0
    def it_returns_html_when_sharing(app):
        with app.test_request_context():
            request_share.args = {'alt': 'foobar', 'share': ['true']}
            html = display("my_title", "my_path", share=True, raw=True)

        print(html)
        assert "<title>my_title</title>" in html
        assert 'src="it\'s a path?alt=foobar"' in html
        assert 'return "it\'s a path?alt=foobar&share=true"' in html
        assert "ga('create', 'my_tid', 'auto');" in html
Пример #12
0
    def it_returns_an_image_otherwise(mock_send_file, mock_track):

        display("my_title", "my_path")

        expect(mock_track.mock_calls) == [call("my_title")]
        expect(mock_send_file.mock_calls) == [call("my_path", mimetype="image/jpeg")]