Пример #1
0
class YahooNews():
    """get yahoo news"""
    industry_url = 'http://finance.yahoo.com/rss/industry?s='
    headline_url = 'http://finance.yahoo.com/rss/headline?s='
    blog_url = 'http://finance.yahoo.com/rss/blog?s='

    def __init__(self):
        self.yql = YQLQuery()

    def getPublicNews(self,symbol,news_type,num_results):
        """Get Industry News from yahoo finance rss through YQL"""

        if news_type is "industry":
            url = self.industry_url + symbol
        elif news_type is "headline":
            url = self.headline_url + symbol
        if news_type is "blog":
            url = self.blog_url + symbol
        q = 'select * from rss where url = \'%s\'' % url
        ret =  self.yql.execute(q)
        return ret['query']['results']['item'][:num_results]
Пример #2
0
 def __init__(self):
     self.yql = YQLQuery()
Пример #3
0
 def test_placeholder_regex_three(self):
     query = YQLQuery("SELECT * from foo where email=@foo and test=@bar'")
     placeholders = query.get_placeholder_keys()
     self.assertEqual(placeholders, ['foo', 'bar'])
Пример #4
0
 def test_placeholder_regex_five(self):
     query = YQLQuery("""SELECT * from foo
                 where foo='bar' LIMIT
                 @foo""")
     placeholders = query.get_placeholder_keys()
     self.assertEqual(placeholders, ['foo'])
Пример #5
0
 def test_requires_substitutions(self):
     query = YQLQuery("SELECT * from foo where dog=@dog")
     query.validate()
Пример #6
0
 def test_placeholder_regex_one(self):
     query = YQLQuery("SELECT * from foo where email='*****@*****.**'")
     placeholders = query.get_placeholder_keys()
     self.assertEqual(placeholders, [])
Пример #7
0
 def test_incorrect_type_raises_valueerror(self):
     query = YQLQuery("SELECT * from foo where dog=@test")
     params = ('fail')
     query.validate(params)
Пример #8
0
 def test_unecessary_args_raises_valueerror(self):
     query = YQLQuery("SELECT * from foo where dog='test'")
     params = {'test': 'fail'}
     query.validate(params)
Пример #9
0
 def test_params_raises_when_not_dict(self):
     query = YQLQuery("SELECT * from foo where dog=@dog")
     params = ['test']
     query.validate(params)
Пример #10
0
 def test_incorrect_args_raises_valueerror(self):
     query = YQLQuery("SELECT * from foo where dog=@dog")
     params = {'test': 'fail'}
     query.validate(params)
Пример #11
0
 def test_empty_args_raises_valueerror(self):
     query = YQLQuery("SELECT * from foo where dog=@dog")
     params = {}
     query.validate(params)