class TestUserStatistics:
    q = Quora()
    stats1 = q.get_user_stats('Christopher-J-Su')
    stats2 = q.get_user_stats('Aaron-Ounn')
    stats3 = q.get_user_stats('Elynn-Lee')
    stats4 = q.get_user_stats('Jennifer-Apacible-1')
    test_stats = [stats1, stats2, stats3, stats4]

    # todo: add tests for nonexistant users and other edge cases

    @classmethod
    def setup_class(cls):
        print "Setup here"

    def test_exists(self):
        for stat in self.test_stats:
            assert stat['answers']
            assert stat['edits']
            assert stat['followers']
            assert stat['following']
            assert stat['questions']
            assert stat['name']
            assert stat['username']

    def test_type(self):
        for stat in self.test_stats:
            assert isinstance(stat['answers'], (int, long))
            assert isinstance(stat['edits'], (int, long))
            assert isinstance(stat['followers'], (int, long))
            assert isinstance(stat['following'], (int, long))
            assert isinstance(stat['posts'], (int, long))
            assert isinstance(stat['questions'], (int, long))
            assert isinstance(stat['name'], str)
            assert isinstance(stat['username'], str)
class TestQuestionStatistics:
    q = Quora()
    stats1 = q.get_question_stats(
        'If-space-is-3-dimensional-can-time-also-be-3-dimensional')
    stats2 = q.get_question_stats(
        'I-need-a-summer-internship-but-I-dont-want-to-apply-because-theres-a-90-chance-Ill-get-rejected-What-should-I-do'
    )
    stats3 = q.get_question_stats(
        'What-are-the-best-intern-blog-posts-and-guides')
    stats4 = q.get_question_stats(
        'What-data-structures-and-algorithms-should-one-implement-in-order-to-prepare-for-technical-interviews'
    )
    test_stats = [stats1, stats2, stats3, stats4]

    # todo: add tests for nonexistant users and other edge cases

    @classmethod
    def setup_class(cls):
        print "Setup here"

    def test_exists(self):
        for stat in self.test_stats:
            assert stat['answer_count']
            assert stat['topics']
            assert stat['want_answers']

    def test_type(self):
        for stat in self.test_stats:
            assert isinstance(stat['answer_count'], (int, long))
            assert isinstance(stat['want_answers'], (int, long))
 def test_correct(self):
     q = Quora()
     stats1 = q.scrape_question_stats(
         BeautifulSoup(open('tests/input_files/question_1')))
     stats2 = q.scrape_question_stats(
         BeautifulSoup(open('tests/input_files/question_2')))
     assert stats1 == EXPECTED_STATS_1
     assert stats2 == EXPECTED_STATS_2
Exemple #4
0
    def test_correct(self):
        q = Quora()
        stats1 = q.scrape_one_answer(BeautifulSoup(open('tests/input_files/answer_1')))

        assert stats1 == EXPECTED_STATS_1
 def __init__(self, user):
     quora = Quora()
     self.activity = quora.get_activity(user)
     self.user = user
Exemple #6
0
from baidu import Baidu
from exalead import Exalead
from quora import Quora
from youtube import Youtube
from parsijoo import Parsijoo

scrapers = {
    'g': Google(),
    'b': Bing(),
    'y': Yahoo(),
    'd': Duckduckgo(),
    'a': Ask(),
    'yd': Yandex(),
    'u': Baidu(),
    'e': Exalead(),
    'q': Quora(),
    't': Youtube(),
    'p': Parsijoo()
}


def read_in():
    lines = sys.stdin.readlines()
    return json.loads(lines[0])


def small_test():
    assert isinstance(scrapers.google.results_search('fossasia'), list)


def feedgen(query, engine, count=10):
Exemple #7
0
from quora import Quora
from yahoo import Yahoo
from yandex import Yandex
from youtube import Youtube

scrapers = {
    'ask': Ask(),
    'baidu': Baidu(),
    'bing': Bing(),
    'dailymotion': Dailymotion(),
    'duckduckgo': Duckduckgo(),
    'exalead': Exalead(),
    'google': Google(),
    'mojeek': Mojeek(),
    'parsijoo': Parsijoo(),
    'quora': Quora(),
    'yahoo': Yahoo(),
    'yandex': Yandex(),
    'youtube': Youtube()
}


def small_test():
    assert isinstance(scrapers['google'].search('fossasia'), list)


def feedgen(query, engine, count=10):
    engine = engine.lower()
    # provide temporary backwards compatibility for old names
    old_names = {
        'ubaidu': 'baidu',