def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.GET, 'https://news.ycombinator.com/', body=get_content('index.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'best'), body=get_content('best.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'newest'), body=get_content('newest.html')) # check py version PY2 = sys.version_info[0] == 2 if not PY2: self.text_type = [str] else: self.text_type = [unicode, str] self.hn = HN() self.top_stories = [story for story in self.hn.get_stories()] self.newest_stories = [story for story in self.hn.get_stories( story_type='newest')] self.best_stories = [story for story in self.hn.get_stories( story_type='best')]
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.GET, 'https://news.ycombinator.com/', body=get_content('index.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'item?id=6115341'), body=get_content('6115341.html')) # check py version self.PY2 = sys.version_info[0] == 2 self.hn = HN() self.story = Story.fromid(6115341)
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.HTTPretty.GET, 'http://thezine.biz/issue-4/bubble', body=get_content('article.html')) self.contact = Article.fromLink('issue-4/bubble').author.contact
def setUp(self): # check py version #self.PY2 = sys.version_info[0] == 2 self.hn = HN() httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'leaders'), body=get_content('leaders.html'))
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.GET, 'https://news.ycombinator.com/', body=get_content('index.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'best'), body=get_content('best.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'newest'), body=get_content('newest.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'x?fnid=WK2fLO5cPAJ9DnZbm8XOFR'), body=get_content('best2.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'news2'), body=get_content('news2.html')) # check py version self.PY2 = sys.version_info[0] == 2 self.hn = HN()
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'item?id=6115341'), body=get_content('6115341.html')) self.PY2 = sys.version_info[0] == 2 if not self.PY2: self.text_type = [str] else: self.text_type = [unicode, str] # https://news.ycombinator.com/item?id=6115341 self.story = Story.fromid(6115341)
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.GET, 'https://news.ycombinator.com/', body=get_content('index.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'item?id=7324236'), body=get_content('7324236.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'x?fnid=0MonpGsCkcGbA7rcbd2BAP'), body=get_content('7324236-2.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'x?fnid=jyhCSQtM6ymFazFplS4Gpf'), body=get_content('7324236-3.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'x?fnid=s3NA4qB6zMT3KHVk1x2MTG'), body=get_content('7324236-4.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'x?fnid=pFxm5XBkeLtmphVejNZWlo'), body=get_content('7324236-5.html')) story = Story.fromid(7324236) self.comments = story.get_comments()
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.GET, 'https://news.ycombinator.com/', body=get_content('index.html')) httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'item?id=7324236'), body=get_content('7324236.html')) httpretty.register_uri( httpretty.GET, '%s/%s' % (constants.BASE_URL, 'x?fnid=0MonpGsCkcGbA7rcbd2BAP'), body=get_content('7324236-2.html')) httpretty.register_uri( httpretty.GET, '%s/%s' % (constants.BASE_URL, 'x?fnid=jyhCSQtM6ymFazFplS4Gpf'), body=get_content('7324236-3.html')) httpretty.register_uri( httpretty.GET, '%s/%s' % (constants.BASE_URL, 'x?fnid=s3NA4qB6zMT3KHVk1x2MTG'), body=get_content('7324236-4.html')) httpretty.register_uri( httpretty.GET, '%s/%s' % (constants.BASE_URL, 'x?fnid=pFxm5XBkeLtmphVejNZWlo'), body=get_content('7324236-5.html')) story = Story.fromid(7324236) self.comments = story.get_comments()
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.HTTPretty.GET, 'http://thezine.biz', body=get_content('index.html')) self.tz = TZ() self.articles = self.tz.get_articles(1) self.dummy_articles = [{ 'author': ' \xe2\x80\x94 Meghna Gulati', 'link': u'issue-1/editorial', 'title': u'The Editorial' }, { 'author': ' \xe2\x80\x94 Tanya Dutta', 'link': u'issue-1/smiles-tears', 'title': u'Of Smiles and Tears' }, { 'author': ' \xe2\x80\x94 Anirban Chattopadhyaya', 'link': u'issue-1/plato', 'title': u'Plato Speak' }, { 'author': ' \xe2\x80\x94 Zaid Drabu', 'link': u'issue-1/slam', 'title': u'Slam!' }, { 'author': ' \xe2\x80\x94 Prakriti Anand', 'link': u'issue-1/perspective', 'title': u'Perspective' }, { 'author': ' \xe2\x80\x94 Meghna Gulati', 'link': u'issue-1/possible', 'title': u'I. M. Possible' }, { 'author': ' \xe2\x80\x94 Rahat Chawla', 'link': u'issue-1/review', 'title': u'The Good & the Bad' }, { 'author': ' \xe2\x80\x94 Yash Sharma', 'link': u'issue-1/travel', 'title': u'Travel' }, { 'author': ' \xe2\x80\x94 Kanika Rana', 'link': u'issue-1/death', 'title': u'If I Could Save Time in a Bottle' }]
def setUp(self): # check py version # #self.PY2 = sys.version_info[0] == 2 self.hn = HN() httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.GET, '%s/%s' % (constants.BASE_URL, 'leaders'), body=get_content('leaders.html')) def tearDown(self): httpretty.HTTPretty.disable() def test_get_leaders_with_no_parameter(self): result = [leader for leader in self.hn.get_leaders()] self.assertEqual(len(result), 10) def test_get_leaders_with_parameter(self): value = 50 result = [leader for leader in self.hn.get_leaders(value)] self.assertEqual(len(result), value)
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.HTTPretty.GET,'http://growthhackers.com/category/engagement/',body=get_content('gh_category.html')) self.category = Category.from_soup(BeautifulSoup(get_content('gh_category.html')))
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.HTTPretty.GET,'http://thezine.biz/issue-4/bubble',body=get_content('article.html')) self.article = Article.fromLink('issue-4/bubble')
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.HTTPretty.GET,'http://growthhackers.com/member/everette/',body=get_content('gh_user.html')) self.author = User.from_user_id('everette')
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.HTTPretty.GET,'http://growthhackers.com/how-a-tiny-startup-used-reddit-to-build-an-army-of-1400-ambassadors-and-how-you-can-too/#comment-11694',body=get_content('gh_comment.html')) self.comment = Comment.from_soup(BeautifulSoup(get_content('gh_comment.html')))
def setUp(self): httpretty.HTTPretty.enable() httpretty.register_uri(httpretty.HTTPretty.GET,'http://growthhackers.com/the-ultimate-customer-loyalty-guidebook-6000-words/',body=get_content('gh_post.html')) self.post = Post.from_post_id('the-ultimate-customer-loyalty-guidebook-6000-words')