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'
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'
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)
def get_hash(name): return hashlib.sha1(binary(name)).hexdigest()
def test_binary(): assert binary(b'test') == b'test' assert binary(text_type('Test')) == b'Test'