Example #1
0
 def test_content_no_params(self):
     """
     Test that the sentiment API returns something 
     when start and end are not specified
     """
     data = tweet_sentiment.sentiments('GOOG')
     self.assertTrue(len(data) > 0)
Example #2
0
def labmt_sentiment_on_company(request, stock_symbol):
    """
    Return sentiment analysis for a company matching a stock symbol. 
    It is possible to define URL parameters to filter on start
    and end Epoch timestamps. The sentiment is done on a labmt file.
    """
    try:
        start = request.GET.get('start')
        if start:
            start = int(start)
        end = request.GET.get('end')
        if end:
            end = int(end)
    except:
        error = _error_message('Start and end parameters must\
         be in valid UNIX timestamp format')
        return HttpResponse(error, status=400, mimetype='application/json')

    s_data = sentiments(stock_symbol, method='labmt', start=start, end=end)
    return HttpResponse(json.dumps(s_data), mimetype='application/json')
Example #3
0
 def test_non_content(self):
     """Test that the sentiment API returns nothing when the time range is wrong"""
     data = tweet_sentiment.sentiments('GOOG', start=time.time(), end=time.time()-864000)
     self.assertEqual(len(data), 0)
Example #4
0
 def test_content(self):
     """Test that the sentiment API returns something"""
     data = tweet_sentiment.sentiments('GOOG', start=time.time()-864000, end=time.time())
     self.assertTrue(len(data) > 0)