Comments
This commit is contained in:
		
							parent
							
								
									fc8cc85a04
								
							
						
					
					
						commit
						896d3b0cf6
					
				
					 17 changed files with 286 additions and 108 deletions
				
			
		
							
								
								
									
										4
									
								
								tests/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests/__init__.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | |||
| from piped_api import PipedClient | ||||
| 
 | ||||
| 
 | ||||
| CLIENT = PipedClient() | ||||
							
								
								
									
										34
									
								
								tests/test_comments.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								tests/test_comments.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| from tests import CLIENT | ||||
| 
 | ||||
| 
 | ||||
| def test_comments(video_id: str='dQw4w9WgXcQ') -> None: | ||||
|     """ | ||||
|         Prints out first 20 pages of comments from a video. | ||||
|     """ | ||||
| 
 | ||||
|     at_page = 0 | ||||
|     max_pages = 5 | ||||
|     total_comments = 0 | ||||
|     np = None | ||||
| 
 | ||||
|     while at_page < max_pages: | ||||
|         comments = CLIENT.get_comments(video_id, nextpage=np) | ||||
|         at_page += 1 | ||||
| 
 | ||||
|         print('=' * 35, f'Page: {at_page}', '=' * 35) | ||||
|         for comment in comments.get_comments(): | ||||
|             total_comments += 1 | ||||
|             print(f'Comment {comment.comment_id} by "{comment.author}" ({comment.commented_time}), {comment.like_count} likes: "{comment.comment_text}"') | ||||
| 
 | ||||
|         if comments.nextpage == None: | ||||
|             print(f"No more comments! Total: {total_comments}, expected: {max_pages * 20}") | ||||
|             break | ||||
| 
 | ||||
|         np = comments.nextpage | ||||
|      | ||||
|     print(f"Okay, that's enough comments... Total: {total_comments}, expected: {max_pages * 20}") | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     test_comments() | ||||
|  | @ -1,12 +0,0 @@ | |||
| from python_project_template import infinitum | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| def test_infinitum(): | ||||
|     """ | ||||
|         Tests the infinite random number generator. | ||||
|     """ | ||||
| 
 | ||||
|     for random in infinitum(): | ||||
|         assert type(random) == int | ||||
|         break | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue