zulip: Add hash_util_decode() to decode server encoded URL excerpts.
This adds hash_util_decode() to decode a hash_util_encode() [present in zulip/zulip's zerver/lib/url_encoding.py [1]] encoded string. The intent is to facilitate code sharing among various python clients (primarily, Zulip Terminal). The string replacement before the `unquote` is to recoup for the custom string replacements in zulip/zulip's zerver/lib/url_encoding.py [1]. Test added. [1] See hash_util_encode() in https://github.com/zulip/zulip/blob/master/zerver/lib/url_encoding.py.
This commit is contained in:
		
							parent
							
								
									e992f14522
								
							
						
					
					
						commit
						9a4abb9f87
					
				
					 2 changed files with 35 additions and 0 deletions
				
			
		
							
								
								
									
										23
									
								
								zulip/tests/test_hash_util_decode.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								zulip/tests/test_hash_util_decode.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | |||
| #!/usr/bin/env python3 | ||||
| 
 | ||||
| import unittest | ||||
| import zulip | ||||
| 
 | ||||
| from unittest import TestCase | ||||
| 
 | ||||
| class TestHashUtilDecode(TestCase): | ||||
|     def test_hash_util_decode(self) -> None: | ||||
|         tests = [ | ||||
|             ('topic', 'topic'), | ||||
|             ('.2Edot', '.dot'), | ||||
|             ('.23stream.20name', '#stream name'), | ||||
|             ('(no.20topic)', '(no topic)'), | ||||
|             ('.3Cstrong.3Ebold.3C.2Fstrong.3E', '<strong>bold</strong>'), | ||||
|             ('.3Asome_emoji.3A', ':some_emoji:'), | ||||
|         ] | ||||
|         for encoded_string, decoded_string in tests: | ||||
|             with self.subTest(encoded_string=encoded_string): | ||||
|                 self.assertEqual(zulip.hash_util_decode(encoded_string), decoded_string) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     unittest.main() | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Preet Mishra
						Preet Mishra