예제 #1
0
파일: web_test.py 프로젝트: 0hoo/web
def test_invalid_path(xmls):
    with app.test_client() as client:
        feed_id = hashlib.sha1(
            binary('http://feedone.com/feed/atom/')).hexdigest()
        r = client.get('/non-exist-category/feeds/' + feed_id + '/entries/')
        result = json.loads(r.data)
        assert r.status_code == 404
        assert result['error'] == 'category-id-invalid'
예제 #2
0
파일: web_test.py 프로젝트: calvin/web
def test_invalid_path(xmls):
    with app.test_client() as client:
        feed_id = hashlib.sha1(
            binary('http://feedone.com/feed/atom/')).hexdigest()
        r = client.get('/non-exist-category/feeds/' + feed_id + '/entries/')
        result = json.loads(r.data)
        assert r.status_code == 404
        assert result['error'] == 'category-id-invalid'
예제 #3
0
파일: web_test.py 프로젝트: 0hoo/web
def test_delete_feed(xmls, fx_test_stage):
    with app.test_client() as client:
        feed_id = hashlib.sha1(
            binary('http://feedthree.com/feed/atom/')).hexdigest()
        r = client.delete('/feeds/' + feed_id + '/')
        assert r.status_code == 200
        result = json.loads(r.data)
        for child in result['feeds']:
            assert child['title'] != 'Feed Three'
예제 #4
0
파일: web_test.py 프로젝트: calvin/web
def test_delete_feed(xmls, fx_test_stage):
    with app.test_client() as client:
        feed_id = hashlib.sha1(
            binary('http://feedthree.com/feed/atom/')).hexdigest()
        r = client.delete('/feeds/' + feed_id + '/')
        assert r.status_code == 200
        result = json.loads(r.data)
        for child in result['feeds']:
            assert child['title'] != 'Feed Three'
예제 #5
0
파일: app.py 프로젝트: klutzy/web
def delete_feed(category_id, feed_id):
    cursor = Cursor(category_id)
    target = None
    for subscription in cursor:
        if isinstance(subscription, Subscription):
            if feed_id == hashlib.sha1(
                    binary(subscription.feed_uri)).hexdigest():
                target = subscription
    if target:
        cursor.discard(target)
    else:
        r = jsonify(
            error='feed-not-found-in-path',
            message='Given feed does not exist in the path'
        )
        r.status_code = 400
        return r
    with get_stage() as stage:
        stage.subscriptions = cursor.subscriptionlist
    return feeds(category_id)
예제 #6
0
def get_hash(name):
    return hashlib.sha1(binary(name)).hexdigest()
예제 #7
0
def get_hash(name):
    return hashlib.sha1(binary(name)).hexdigest()
예제 #8
0
def test_binary():
    assert binary(b'test') == b'test'
    assert binary(text_type('Test')) == b'Test'