Example #1
0
def get_stories(page=None):
    """Return a page of HN stories"""
    if request.url_rule.rule in ('/ask', '/ask/'):
        page = 'ask'
    elif request.url_rule.rule in ('/stories/', '/stories'):
        page = ''

    try:
        resp = items.get_stories(page)
    except exceptions.NotFound:
        abort(404)

    return app.response_class(resp, mimetype='application/json')
Example #2
0
 def test_get_stories(self):
     with mock.patch.object(items, '_get_cache') as get_cache:
         items.get_stories('test_id')
         get_cache.assert_called_with('/pages/x?fnid=test_id',
                                      'x?fnid=test_id')
Example #3
0
 def test_get_stories(self):
     with mock.patch.object(items, '_get_cache') as get_cache:
         items.get_stories('test_id')
         get_cache.assert_called_with('/pages/x?fnid=test_id',
                                      'x?fnid=test_id')