コード例 #1
0
def test_put():
    app = create_app()

    t1 = time()
    rv = app.test_client().post('/', data=dict(c=str(t1)))
    data = load(rv.get_data())

    assert data.get('uuid')
    assert data.get('url')
    assert 'redacted' not in data.get('uuid')

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))

    f = lambda c: app.test_client().put(url, data=dict(c=str(c) if c else c))

    rv = f(None)
    assert rv.status_code == 400

    rv = f(t1)
    assert load(rv.get_data())['status'] == 'already exists'

    t2 = time()
    rv = f(t2)
    assert rv.status_code == 200

    rv = app.test_client().get(load(rv.get_data())['url'])
    assert rv.get_data().decode('utf-8') == str(t2)
コード例 #2
0
ファイル: test_paste_vanity.py プロジェクト: hguemar/pb
def test_paste_vanity():
    app = create_app()

    c = str(time())
    rv = app.test_client().post('/foo123', data=dict(
        c = c
    ))
    location = rv.headers.get('Location')
    assert 'foo123' in location
    data = load(rv.get_data())

    rv = app.test_client().get(location)
    assert rv.status_code == 200
    assert rv.get_data() == c.encode('utf-8')

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))
    
    rv = app.test_client().put(url, data=dict(
        c = str(time())
    ))
    assert rv.status_code == 200

    rv = app.test_client().delete(url)
    assert rv.status_code == 200
コード例 #3
0
ファイル: test_paste_private.py プロジェクト: rmcintosh/pb
def test_insert_private():
    app = create_app()

    c = str(time())
    rv = app.test_client().post('/', data=dict(c=c, p=1))

    data = load(rv.get_data())
    assert sha1(c.encode('utf-8')).hexdigest() in data['sha1']

    rv = app.test_client().get(data['url'])
    assert rv.status_code == 200

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))

    f = lambda c: app.test_client().put(url, data=dict(c=c))

    rv = f(c)
    assert load(rv.get_data())['status'] == 'already exists'

    rv = f(str(time()))
    assert load(rv.get_data())['status'] == 'updated'

    rv = app.test_client().delete(url)
    assert load(rv.get_data())['status'] == 'deleted'
コード例 #4
0
ファイル: test_paste.py プロジェクト: GermainZ/pb
def test_post_content():
    app = create_app()

    rv = app.test_client().post('/')
    assert rv.status_code == 400

    rv = app.test_client().post('/', data=dict(
        c = str(time())
    ))
    assert rv.status_code == 302

    location = rv.headers.get('Location')
    assert location

    rv = app.test_client().get(location)
    assert rv.status_code == 200

    url_path = parse.urlsplit(location).path
    id = b66_int(path.split(url_path)[-1])
    assert id != 0

    with app.test_request_context():
        url = url_for('paste.get', b66=id+10)

    rv = app.test_client().get(url)
    assert rv.status_code == 404
コード例 #5
0
def test_paste_mangle():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.post')

    rv = app.test_client().post(url, data=dict(
        c = str(time())
    ))

    location = rv.headers.get('Location') 
    url_path = parse.urlsplit(location).path
    id = b66_int(path.split(url_path)[-1])

    assert id != 0

    tests = [
        ({'lexer': 'py'}, 200),
        ({'lexer': ''}, 200),
        ({'lexer': 'buhLang'}, 400),
        ({'handler': 'r'}, 200),
        ({'handler': 'Z'}, 400)
    ]

    for kwargs, code in tests:
        with app.test_request_context():
            url = url_for('paste.get', b66=id, **kwargs)

        rv = app.test_client().get(url)
        assert rv.status_code == code
コード例 #6
0
ファイル: test_paste_vanity.py プロジェクト: ptpb/pb
def test_paste_vanity():
    app = create_app()

    c = str(time())
    rv = app.test_client().post('/~foo1234', data=dict(
        c=c
    ))

    data = load(rv.get_data())
    assert 'foo1234' in data['url']

    rv = app.test_client().get(data['url'])
    assert rv.status_code == 200
    assert rv.get_data() == c.encode('utf-8')

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))

    rv = app.test_client().put(url, data=dict(
        c=str(time())
    ))
    assert rv.status_code == 200

    rv = app.test_client().delete(url)
    assert rv.status_code == 200
コード例 #7
0
ファイル: test_paste_mutable.py プロジェクト: ptpb/pb
def test_delete():
    app = create_app()

    rv = app.test_client().post('/', data=dict(
        c='delete me KU7cC3JBrz0jMXYRCWsZ6YGa/YTYIZWw'
    ))
    data = load(rv.get_data())
    assert 'redacted' not in data.get('uuid')

    with app.test_request_context():
        url = url_for('paste.delete', uuid=data.get('uuid'))

    rv = app.test_client().delete(url)
    assert rv.status_code == 200

    rv = app.test_client().delete(url)
    assert rv.status_code == 404

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))

    rv = app.test_client().put(url, data=dict(
        c=str(time())
    ))
    assert rv.status_code == 404
コード例 #8
0
ファイル: test_paste_private.py プロジェクト: GermainZ/pb
def test_insert_private():
    app = create_app()

    c = str(time())
    rv = app.test_client().post('/', data=dict(
        c = c,
        p = 1
    ))
    location = rv.headers.get('Location')
    data = load(rv.get_data())
    assert sha1(c.encode('utf-8')).hexdigest() in location

    rv = app.test_client().get(location)
    assert rv.status_code == 200

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))
    
    f = lambda c: app.test_client().put(url, data=dict(
        c = c
    ))

    rv = f(c)
    assert rv.status_code == 409

    rv = f(str(time()))
    assert rv.status_code == 200

    rv = app.test_client().delete(url)
    assert rv.status_code == 200
コード例 #9
0
ファイル: test_paste_mutable.py プロジェクト: jstoone/pb
def test_put():
    app = create_app()

    t1 = time()
    rv = app.test_client().post("/", data=dict(c=str(t1)))
    data = load(rv.get_data())

    assert data.get("uuid")
    assert data.get("url")
    assert "redacted" not in data.get("uuid")

    with app.test_request_context():
        url = url_for("paste.put", uuid=data.get("uuid"))

    f = lambda c: app.test_client().put(url, data=dict(c=str(c) if c else c))

    rv = f(None)
    assert rv.status_code == 400

    rv = f(t1)
    assert load(rv.get_data())["status"] == "already exists"

    t2 = time()
    rv = f(t2)
    assert rv.status_code == 200

    rv = app.test_client().get(load(rv.get_data())["url"])
    assert rv.get_data().decode("utf-8") == str(t2)
コード例 #10
0
ファイル: test_paste_mutable.py プロジェクト: ptpb/pb
def test_put():
    app = create_app()

    t1 = time()
    rv = app.test_client().post('/', data=dict(
        c=str(t1)
    ))
    data = load(rv.get_data())

    assert data.get('uuid')
    assert data.get('url')
    assert 'redacted' not in data.get('uuid')

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))

    def f(c):
        return app.test_client().put(url, data=dict(
            c=str(c) if c else c
        ))

    rv = f(None)
    assert rv.status_code == 400

    rv = f(t1)
    assert load(rv.get_data())['status'] == 'already exists'

    t2 = time()
    rv = f(t2)
    assert rv.status_code == 200

    rv = app.test_client().get(load(rv.get_data())['url'])
    assert rv.get_data().decode('utf-8') == str(t2)
コード例 #11
0
ファイル: test_paste_private.py プロジェクト: ptpb/pb
def test_insert_private():
    app = create_app()

    c = str(time())
    rv = app.test_client().post('/', data=dict(
        c=c,
        p=1
    ))

    data = load(rv.get_data())
    assert sha1(c.encode('utf-8')).hexdigest() == data['digest']

    rv = app.test_client().get(data['url'])
    assert rv.status_code == 200

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))

    def f(c):
        return app.test_client().put(url, data=dict(
            c=c
        ))

    rv = f(c)
    assert load(rv.get_data())['status'] == 'already exists'

    rv = f(str(time()))
    assert load(rv.get_data())['status'] == 'updated'

    rv = app.test_client().delete(url)
    assert load(rv.get_data())['status'] == 'deleted'
コード例 #12
0
ファイル: test_paste_static.py プロジェクト: HalosGhost/pb
def test_get_lexers():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.list_lexers')

    rv = app.test_client().get(url)
    assert rv.status_code == 200
コード例 #13
0
ファイル: test_paste_static.py プロジェクト: HalosGhost/pb
def test_get_css():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.highlight_css', style='default')

    rv = app.test_client().get(url)
    assert rv.status_code == 200
コード例 #14
0
def test_get_mimetype():
    app = create_app()

    rv = app.test_client().post('/', data=dict(c=str('ello')))

    rv = app.test_client().get('{}.py'.format(load(rv.get_data())['url']))

    assert 'text/x-python' in rv.headers.get('Content-Type')
コード例 #15
0
def test_get_lexers():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.list_lexers')

    rv = app.test_client().get(url)
    assert rv.status_code == 200
コード例 #16
0
def test_get_css():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.highlight_css', style='default')

    rv = app.test_client().get(url)
    assert rv.status_code == 200
コード例 #17
0
ファイル: test_paste.py プロジェクト: jstoone/pb
def test_get_mimetype():
    app = create_app()

    rv = app.test_client().post("/", data=dict(c=str("ello")))

    rv = app.test_client().get("{}.py".format(load(rv.get_data())["url"]))

    assert "text/x-python" in rv.headers.get("Content-Type")
コード例 #18
0
ファイル: test_paste.py プロジェクト: hguemar/pb
def test_get_mimetype():
    app = create_app()

    rv = app.test_client().post('/', data=dict(
        c = str('ello')
    ))

    rv = app.test_client().get('{}.py'.format(rv.headers.get('Location')))

    assert 'text/x-python' in rv.headers.get('Content-Type')
コード例 #19
0
def test_paste_render():
    app = create_app()

    rv = app.test_client().post('/', data=dict(c=str(time())))

    data = load(rv.get_data())
    with app.test_request_context():
        url = url_for('paste.get', handler='r', label=data['short'])

    rv = app.test_client().get(url)
    assert rv.status_code == 200
コード例 #20
0
ファイル: test_url.py プロジェクト: rmcintosh/pb
def test_url_get():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.url')

    rv = app.test_client().post(url, data=dict(c=str(time())))
    location = rv.headers.get('Location')
    assert location

    rv = app.test_client().get(location)
    assert rv.status_code == 302
コード例 #21
0
def test_get_digest():
    app = create_app()

    c = str(time())
    app.test_client().post('/', data=dict(c=c))

    digest = sha1(c.encode('utf-8')).hexdigest()
    with app.test_request_context():
        url = url_for('paste.get', sha1=digest)

    rv = app.test_client().get(url)
    assert rv.status_code == 200
コード例 #22
0
ファイル: test_paste.py プロジェクト: jstoone/pb
def test_post_file():
    app = create_app()

    c = urandom(24)
    ext = int(time())
    rv = app.test_client().post("/", data=dict(c=(BytesIO(c), "foo.{}".format(ext))))

    data = load(rv.get_data())
    assert ".{}".format(ext) in data["url"]

    rv = app.test_client().get(data["url"])
    assert c == rv.get_data()
コード例 #23
0
def test_post_file(field_name):
    app = create_app()

    content = urandom(24)
    ext = int(time())
    rv = app.test_client().post(
        '/', data={field_name: (BytesIO(content), 'foo.{}'.format(ext))})

    data = load(rv.get_data())
    assert '.{}'.format(ext) in data['url']

    rv = app.test_client().get(data['url'])
    assert rv.get_data() == content
コード例 #24
0
ファイル: test_paste_handler.py プロジェクト: ptpb/pb
def test_paste_render():
    app = create_app()

    rv = app.test_client().post('/', data=dict(
        c=str(time())
    ))

    data = load(rv.get_data())
    with app.test_request_context():
        url = url_for('paste.get', handler='r', label=data['short'])

    rv = app.test_client().get(url)
    assert rv.status_code == 200
コード例 #25
0
def test_paste_mangle():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.post')

    rv = app.test_client().post(url, data=dict(
        c = str(time())
    ))

    location = rv.headers.get('Location')
    url_path = parse.urlsplit(location).path
    """ FIXME
コード例 #26
0
ファイル: test_url.py プロジェクト: HalosGhost/pb
def test_url_get():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.url')

    rv = app.test_client().post(url, data=dict(
        c = str(time())
    ))
    location = rv.headers.get('Location')
    assert location

    rv = app.test_client().get(location)
    assert rv.status_code == 302
コード例 #27
0
ファイル: test_paste.py プロジェクト: hguemar/pb
def test_post_file():
    app = create_app()

    c = urandom(24)
    ext = int(time())
    rv = app.test_client().post('/', data=dict(
        c = (BytesIO(c), 'foo.{}'.format(ext))
    ))

    location = rv.headers.get('Location')
    assert '.{}'.format(ext) in location

    rv = app.test_client().get(location)
    assert c == rv.get_data()
コード例 #28
0
def test_post_content():
    app = create_app()

    rv = app.test_client().post('/')
    assert rv.status_code == 400

    rv = app.test_client().post('/', data=dict(c=str(time())))
    assert rv.status_code == 200

    data = load(rv.get_data())
    assert data['url']

    rv = app.test_client().get(data['url'])
    assert rv.status_code == 200
コード例 #29
0
ファイル: test_paste.py プロジェクト: ptpb/pb
def test_post_file(field_name):
    app = create_app()

    content = urandom(24)
    ext = int(time())
    rv = app.test_client().post('/', data={
        field_name: (BytesIO(content), 'foo.{}'.format(ext))
    })

    data = load(rv.get_data())
    assert '.{}'.format(ext) in data['url']

    rv = app.test_client().get(data['url'])
    assert rv.get_data() == content
コード例 #30
0
ファイル: test_paste_sha1.py プロジェクト: GermainZ/pb
def test_get_digest():
    app = create_app()

    c = str(time())
    app.test_client().post('/', data=dict(
        c = c
    ))

    digest = sha1(c.encode('utf-8')).digest()
    with app.test_request_context():
        url = url_for('paste.get', sha1=digest)

    rv = app.test_client().get(url)
    assert rv.status_code == 200
コード例 #31
0
ファイル: test_paste.py プロジェクト: jstoone/pb
def test_post_content():
    app = create_app()

    rv = app.test_client().post("/")
    assert rv.status_code == 400

    rv = app.test_client().post("/", data=dict(c=str(time())))
    assert rv.status_code == 200

    data = load(rv.get_data())
    assert data["url"]

    rv = app.test_client().get(data["url"])
    assert rv.status_code == 200
コード例 #32
0
ファイル: test_paste.py プロジェクト: GermainZ/pb
def test_post_file():
    app = create_app()

    c = urandom(24)
    ext = int(time())
    rv = app.test_client().post('/',
                                data=dict(c=(BytesIO(c),
                                             'foo.{}'.format(ext))))

    location = rv.headers.get('Location')
    assert '.{}'.format(ext) in location

    rv = app.test_client().get(location)
    assert c == rv.get_data()
コード例 #33
0
def test_post_file():
    app = create_app()

    c = urandom(24)
    ext = int(time())
    rv = app.test_client().post('/',
                                data=dict(c=(BytesIO(c),
                                             'foo.{}'.format(ext))))

    data = load(rv.get_data())
    assert '.{}'.format(ext) in data['url']

    rv = app.test_client().get(data['url'])
    assert c == rv.get_data()
コード例 #34
0
ファイル: delete.py プロジェクト: ptpb/pb
def main():
    ns = parser.parse_args()

    res = requests.request('REPORT', f'{ns.endpoint}/{ns.id}', headers={
        'accept': 'application/json'
    })

    assert res.ok

    digest = res.json()['digest']

    app = create_app()
    with app.app_context():
        with app.test_request_context(ns.endpoint):
            delete_paste(digest)
コード例 #35
0
ファイル: test_paste.py プロジェクト: GermainZ/pb
def test_post_unqiue():
    app = create_app()

    f = lambda c: app.test_client().post('/', data=dict(c=str(c)))

    rv1 = f(monotonic())
    rv2 = f(monotonic())

    assert rv1.headers.get('Location') != rv2.headers.get('Location')

    c = time()
    rv1 = f(c)
    rv2 = f(c)

    assert rv1.headers.get('Location') == rv2.headers.get('Location')
コード例 #36
0
ファイル: delete.py プロジェクト: imfht/flaskapps
def main():
    ns = parser.parse_args()

    res = requests.request('REPORT',
                           f'{ns.endpoint}/{ns.id}',
                           headers={'accept': 'application/json'})

    assert res.ok

    digest = res.json()['digest']

    app = create_app()
    with app.app_context():
        with app.test_request_context(ns.endpoint):
            delete_paste(digest)
コード例 #37
0
ファイル: test_paste.py プロジェクト: jstoone/pb
def test_post_unique():
    app = create_app()

    f = lambda c: app.test_client().post("/", data=dict(c=str(c)))

    rv1 = f(monotonic())
    rv2 = f(monotonic())

    assert load(rv1.get_data())["url"] != load(rv2.get_data())["url"]

    c = time()
    rv1 = f(c)
    rv2 = f(c)

    assert load(rv1.get_data())["url"] == load(rv2.get_data())["url"]
コード例 #38
0
ファイル: test_url.py プロジェクト: rmcintosh/pb
def test_url_post():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.url')

    rv = app.test_client().post(url)
    assert rv.status_code == 400

    f = lambda c: app.test_client().post(url, data=dict(c=str(c)))
    rv = f(shorturl)
    assert rv.status_code == 200

    rv = f(time())
    assert rv.status_code == 200
コード例 #39
0
ファイル: test_paste.py プロジェクト: hguemar/pb
def test_post_content():
    app = create_app()

    rv = app.test_client().post('/')
    assert rv.status_code == 400

    rv = app.test_client().post('/', data=dict(
        c = str(time())
    ))
    assert rv.status_code == 302

    location = rv.headers.get('Location')
    assert location

    rv = app.test_client().get(location)
    assert rv.status_code == 200
コード例 #40
0
def test_post_content(field_name):
    app = create_app()

    rv = app.test_client().post('/')
    assert rv.status_code == 400

    content = str(time())
    rv = app.test_client().post('/', data={field_name: content})
    assert rv.status_code == 200

    data = load(rv.get_data())
    assert data['url']

    rv = app.test_client().get(data['url'])
    assert rv.status_code == 200
    assert rv.get_data() == content.encode('utf-8')
コード例 #41
0
def test_post_unique():
    app = create_app()

    def f(c):
        return app.test_client().post('/', data=dict(c=str(c)))

    rv1 = f(monotonic())
    rv2 = f(monotonic())

    assert load(rv1.get_data())['url'] != load(rv2.get_data())['url']

    c = time()
    rv1 = f(c)
    rv2 = f(c)

    assert load(rv1.get_data())['url'] == load(rv2.get_data())['url']
コード例 #42
0
ファイル: test_paste.py プロジェクト: hguemar/pb
def test_post_unqiue():
    app = create_app()

    f = lambda c: app.test_client().post('/', data=dict(
        c = str(c)
    ))

    rv1 = f(monotonic())
    rv2 = f(monotonic())

    assert rv1.headers.get('Location') != rv2.headers.get('Location')

    c = time()
    rv1 = f(c)
    rv2 = f(c)

    assert rv1.headers.get('Location') == rv2.headers.get('Location')
コード例 #43
0
ファイル: test_url.py プロジェクト: HalosGhost/pb
def test_url_post():
    app = create_app()

    with app.test_request_context():
        url = url_for('paste.url')

    rv = app.test_client().post(url)
    assert rv.status_code == 400

    f = lambda c: app.test_client().post(url, data=dict(
        c = str(c)
    ))
    rv = f(shorturl)
    assert rv.status_code == 200

    rv = f(time())
    assert rv.status_code == 200
コード例 #44
0
ファイル: test_paste.py プロジェクト: ptpb/pb
def test_post_content(field_name):
    app = create_app()

    rv = app.test_client().post('/')
    assert rv.status_code == 400

    content = str(time())
    rv = app.test_client().post('/', data={
        field_name: content
    })
    assert rv.status_code == 200

    data = load(rv.get_data())
    assert data['url']

    rv = app.test_client().get(data['url'])
    assert rv.status_code == 200
    assert rv.get_data() == content.encode('utf-8')
コード例 #45
0
ファイル: test_paste.py プロジェクト: ptpb/pb
def test_post_unique():
    app = create_app()

    def f(c):
        return app.test_client().post('/', data=dict(
            c=str(c)
        ))

    rv1 = f(monotonic())
    rv2 = f(monotonic())

    assert load(rv1.get_data())['url'] != load(rv2.get_data())['url']

    c = time()
    rv1 = f(c)
    rv2 = f(c)

    assert load(rv1.get_data())['url'] == load(rv2.get_data())['url']
コード例 #46
0
def test_paste_render():
    app = create_app()

    rv = app.test_client().post('/', data=dict(c=str(time())))

    data = load(rv.get_data())
    with app.test_request_context():
        nurl = url_for('paste.get', label=data['short'], lexer='')
        iurl = url_for('paste.get', label=data['short'], lexer='bogus')
        lurl = url_for('paste.get', label=data['short'], lexer='pycon')

    rv1 = app.test_client().get(nurl)
    rv2 = app.test_client().get(iurl)
    rv3 = app.test_client().get(lurl)

    assert rv1.status_code == 200
    assert rv2.status_code == 400
    assert rv3.status_code == 200
コード例 #47
0
ファイル: test_paste_sunset.py プロジェクト: m42e/pb
def test_paste_sunset():
    app = create_app()

    rv = app.test_client().post('/', data=dict(c=str(time()), s=1))

    data = load(rv.get_data())
    with app.test_request_context():
        url = url_for('paste.get', label=data['short'])

    sleep(1)

    rv = app.test_client().get(url)
    data = load(rv.get_data())

    assert data['status'] == 'expired'

    rv = app.test_client().get(url)

    assert rv.status_code == 404
コード例 #48
0
def test_paste_sunset_expire_before_get():
    app = create_app()

    c = str(time())

    app.test_client().post('/', data=dict(
        c=c,
        s=1
    ))

    sleep(1)

    rv = app.test_client().post('/', data=dict(
        c=c,
        s=1
    ))

    assert rv.status_code == 200
    data = load(rv.get_data())
    assert data['status'] == 'created'
コード例 #49
0
ファイル: test_paste_highlight.py プロジェクト: HalosGhost/pb
def test_paste_render():
    app = create_app()

    rv = app.test_client().post('/', data=dict(
        c = str(time())
    ))

    data = load(rv.get_data())
    with app.test_request_context():
        nurl = url_for('paste.get', label=data['short'], lexer='')
        iurl = url_for('paste.get', label=data['short'], lexer='bogus')
        lurl = url_for('paste.get', label=data['short'], lexer='pycon')

    rv1 = app.test_client().get(nurl)
    rv2 = app.test_client().get(iurl)
    rv3 = app.test_client().get(lurl)

    assert rv1.status_code == 200
    assert rv2.status_code == 400
    assert rv3.status_code == 200
コード例 #50
0
ファイル: test_paste_vanity.py プロジェクト: imfht/flaskapps
def test_paste_vanity():
    app = create_app()

    c = str(time())
    rv = app.test_client().post('/~foo1234', data=dict(c=c))

    data = load(rv.get_data())
    assert 'foo1234' in data['url']

    rv = app.test_client().get(data['url'])
    assert rv.status_code == 200
    assert rv.get_data() == c.encode('utf-8')

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))

    rv = app.test_client().put(url, data=dict(c=str(time())))
    assert rv.status_code == 200

    rv = app.test_client().delete(url)
    assert rv.status_code == 200
コード例 #51
0
def test_delete():
    app = create_app()

    rv = app.test_client().post(
        '/', data=dict(c='delete me KU7cC3JBrz0jMXYRCWsZ6YGa/YTYIZWw'))
    data = load(rv.get_data())
    assert 'redacted' not in data.get('uuid')

    with app.test_request_context():
        url = url_for('paste.delete', uuid=data.get('uuid'))

    rv = app.test_client().delete(url)
    assert rv.status_code == 200

    rv = app.test_client().delete(url)
    assert rv.status_code == 404

    with app.test_request_context():
        url = url_for('paste.put', uuid=data.get('uuid'))

    rv = app.test_client().put(url, data=dict(c=str(time())))
    assert rv.status_code == 404
コード例 #52
0
def test_url_get():
    app = create_app()

    with app.test_request_context():
        url = url_for('url.post')

    rv = app.test_client().post(url, data=dict(c=str(time())))
    location = rv.headers.get('Location')
    assert location

    rv = app.test_client().get(location)
    assert rv.status_code == 302

    url_path = parse.urlsplit(location).path
    id = b66_int(path.split(url_path)[-1])
    assert id != 0

    with app.test_request_context():
        url = url_for('url.get', b66=id + 10)

    rv = app.test_client().get(url)
    assert rv.status_code == 404
コード例 #53
0
def test_get_index():
    app = create_app()

    with app.test_request_context():
        rv = app.test_client().get(url_for('paste.index'))
        assert rv.status_code == 200
コード例 #54
0
ファイル: conftest.py プロジェクト: imfht/flaskapps
def app():
    app = create_app()
    return app
コード例 #55
0
ファイル: run.py プロジェクト: GermainZ/pb
#!/usr/bin/env python3
"""
    wsgi stub
    ~~~~~~~~~

    intended to be conveniently used by wsgi servers.

    :copyright: Copyright (C) 2014 by the respective authors; see AUTHORS.
    :license: GPLv3, see LICENSE for details.
"""

from pb.pb import create_app

app = create_app()

if __name__ == '__main__':
    app.run(host='::1', port=10002)