Skip to content

Commit

Permalink
will add more tests after adding more code
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan Goel committed Dec 27, 2013
1 parent ef7742c commit ea15aea
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
22 changes: 21 additions & 1 deletion .coveragerc
Expand Up @@ -2,4 +2,24 @@
omit =
*/python?.?/*
*/site-packages/*
*/test*
*/test*

# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

def __init__
num_comments = 0
points = 0
submitter = ''
submitter_profile = ''
published_time = '%s' % detail_concern[0]
comment_tag = ''
story_id = int(re.match(r'.*=(\d+)', link).groups()[0])
story_id = -1
comments_link = ''
comment_count = -1

if 0:
if __name__ == .__main__.:
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -43,8 +43,8 @@ Usage
hn = HN()

# print the first 2 pages of newest stories
for story in hn.get_stories(story_type='newest', page_limit=2):
print story.rank, story.title
for story in hn.get_stories(story_type='newest', limit=60):
print(story.rank, story.title)

Each `Story` has the following properties

Expand Down
8 changes: 1 addition & 7 deletions hn/hn.py
Expand Up @@ -42,13 +42,7 @@ class HN(object):

def __init__(self):
self.more = ''

def __repr__(self):
"""
A string representation of the class object
"""
return '<HN: more={0}>'.format(self.more)


def _get_next_page(self, soup):
"""
Get the relative url of the next page (The "More" link at
Expand Down
6 changes: 6 additions & 0 deletions tests/test_pagination.py
Expand Up @@ -53,6 +53,12 @@ def test_get_zipped_rows(self):
rows = [row for row in rows]
self.assertEqual(len(rows), 30)

def test_pagination_top_for_0_limit(self):
"""
Checks if the pagination works for 0 limit.
"""
stories = [story for story in self.hn.get_stories(limit=0)]
self.assertEqual(len(stories), 30)

def test_pagination_top_for_2_pages(self):
"""
Expand Down

0 comments on commit ea15aea

Please sign in to comment.