forked from indymedia/epicyon
				
			Unit test for getting mentions
							parent
							
								
									3872426f35
								
							
						
					
					
						commit
						e9c0c4c3a9
					
				
							
								
								
									
										10
									
								
								posts.py
								
								
								
								
							
							
						
						
									
										10
									
								
								posts.py
								
								
								
								
							|  | @ -898,16 +898,6 @@ def createPostBase(baseDir: str, nickname: str, domain: str, port: int, | ||||||
|     if eventUUID: |     if eventUUID: | ||||||
|         postObjectType = 'Event' |         postObjectType = 'Event' | ||||||
| 
 | 
 | ||||||
|     # public posts with mentions should include the mentioned |  | ||||||
|     # actors within CC |  | ||||||
|     # "I think we don’t notify about mentions unless the person |  | ||||||
|     #  is also addressed in to/cc" -- gargron |  | ||||||
|     if toRecipients and toCC and mentionedRecipients: |  | ||||||
|         if len(toRecipients) == 1 and len(toCC) == 1: |  | ||||||
|             if toRecipients[0].endswith('#Public') and \ |  | ||||||
|                toCC[0].endswith('/followers'): |  | ||||||
|                 toCC += mentionedRecipients |  | ||||||
| 
 |  | ||||||
|     if not clientToServer: |     if not clientToServer: | ||||||
|         actorUrl = httpPrefix + '://' + domain + '/users/' + nickname |         actorUrl = httpPrefix + '://' + domain + '/users/' + nickname | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								tests.py
								
								
								
								
							
							
						
						
									
										16
									
								
								tests.py
								
								
								
								
							|  | @ -20,6 +20,7 @@ from cache import getPersonFromCache | ||||||
| from threads import threadWithTrace | from threads import threadWithTrace | ||||||
| from daemon import runDaemon | from daemon import runDaemon | ||||||
| from session import createSession | from session import createSession | ||||||
|  | from posts import getMentionedPeople | ||||||
| from posts import validContentWarning | from posts import validContentWarning | ||||||
| from posts import deleteAllPosts | from posts import deleteAllPosts | ||||||
| from posts import createPublicPost | from posts import createPublicPost | ||||||
|  | @ -2479,8 +2480,23 @@ def testGuessHashtagCategory() -> None: | ||||||
|     assert guess == "bar" |     assert guess == "bar" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def testGetMentionedPeople() -> None: | ||||||
|  |     print('testGetMentionedPeople') | ||||||
|  |     baseDir = os.getcwd() | ||||||
|  | 
 | ||||||
|  |     content = "@dragon@cave.site @bat@cave.site This is a test." | ||||||
|  |     actors = getMentionedPeople(baseDir, 'https', | ||||||
|  |                                 content, | ||||||
|  |                                 'mydomain', False) | ||||||
|  |     assert actors | ||||||
|  |     assert len(actors) == 2 | ||||||
|  |     assert actors[0] == "https://cave.site/users/dragon" | ||||||
|  |     assert actors[1] == "https://cave.site/users/bat" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def runAllTests(): | def runAllTests(): | ||||||
|     print('Running tests...') |     print('Running tests...') | ||||||
|  |     testGetMentionedPeople() | ||||||
|     testGuessHashtagCategory() |     testGuessHashtagCategory() | ||||||
|     testValidNickname() |     testValidNickname() | ||||||
|     testParseFeedDate() |     testParseFeedDate() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue