diff --git a/tests/test_content.py b/tests/test_content.py index 0cdf783..f111910 100644 --- a/tests/test_content.py +++ b/tests/test_content.py @@ -101,7 +101,8 @@ def test_content_submission(reddit, terminal): assert content.get(40)['type'] == 'Comment' for data in content.iterate(-1, 1): - assert all(k in data for k in ('object', 'n_rows', 'offset', 'type')) + assert all(k in data for k in ('object', 'n_rows', 'offset', 'type', + 'hidden')) # All text should be converted to unicode by this point for val in data.values(): assert not isinstance(val, six.binary_type) @@ -121,11 +122,14 @@ def test_content_submission(reddit, terminal): data = content.get(2) assert data['type'] == 'HiddenComment' assert data['count'] == 3 + assert data['hidden'] is True assert data['level'] >= content.get(3)['level'] assert len(content._comment_data) == 43 # Toggling again expands the children content.toggle(2) + data = content.get(2) + assert data['hidden'] is False assert len(content._comment_data) == 45 @@ -195,8 +199,9 @@ def test_content_subreddit(reddit, terminal): assert content.get(0)['type'] == 'Submission' for data in content.iterate(0, 1): - assert all(k in data for k in ('object', 'n_rows', 'offset', 'type', - 'index', 'title', 'split_title')) + assert all(k in data for k in ( + 'object', 'n_rows', 'offset', 'type', 'index', 'title', + 'split_title', 'hidden')) # All text should be converted to unicode by this point for val in data.values(): assert not isinstance(val, six.binary_type) @@ -227,6 +232,7 @@ def test_content_subreddit_load_more(reddit, terminal): assert data['index'] == i + 1 assert data['title'].startswith(six.text_type(i + 1)) + def test_content_subreddit_from_name(reddit, terminal): name = '/r/python' diff --git a/tests/test_objects.py b/tests/test_objects.py index 84bb016..1d2b6f7 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -346,11 +346,13 @@ def test_objects_navigator_properties(): assert nav.step == 1 assert nav.position == (0, 0, False) assert nav.absolute_index == 0 + assert nav.top_item_height is None - nav = Navigator(valid_page_cb, 5, 2, True) + nav = Navigator(valid_page_cb, 5, 2, True, 10) assert nav.step == -1 assert nav.position == (5, 2, True) assert nav.absolute_index == 3 + assert nav.top_item_height == 10 def test_objects_navigator_move(): @@ -360,6 +362,7 @@ def test_objects_navigator_move(): raise IndexError() nav = Navigator(valid_page_cb) + nav.top_item_height = 5 # Try to scroll up past the first item valid, redraw = nav.move(-1, 2) @@ -375,6 +378,7 @@ def test_objects_navigator_move(): # Scroll down, reach last item on the page and flip the screen valid, redraw = nav.move(1, 3) + assert nav.top_item_height is None assert nav.page_index == 2 assert nav.cursor_index == 0 assert nav.inverted