mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-31 10:49:00 +00:00 
			
		
		
		
	 d04092e634
			
		
	
	
		d04092e634
		
			
		
	
	
	
	
		
			
			* feat: add python utility classes for NotebookUrn, CorpuserUrn and CorpGroupUrn Co-authored-by: Xu Wang <xu.wang@grandrounds.com> Co-authored-by: Ravindra Lanka <rslanka@gmail.com>
		
			
				
	
	
		
			26 lines
		
	
	
		
			979 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			979 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import unittest
 | |
| 
 | |
| from datahub.utilities.urns.corpuser_urn import CorpuserUrn
 | |
| from datahub.utilities.urns.error import InvalidUrnError
 | |
| 
 | |
| 
 | |
| class TestCorpuserUrn(unittest.TestCase):
 | |
|     def test_parse_urn(self) -> None:
 | |
|         corpuser_urn_str = "urn:li:corpuser:abc"
 | |
|         corpuser_urn = CorpuserUrn.create_from_string(corpuser_urn_str)
 | |
|         assert corpuser_urn.get_type() == CorpuserUrn.ENTITY_TYPE
 | |
| 
 | |
|         assert corpuser_urn.get_entity_id() == ["abc"]
 | |
|         assert str(corpuser_urn) == corpuser_urn_str
 | |
|         assert corpuser_urn == CorpuserUrn("corpuser", ["abc"])
 | |
|         assert corpuser_urn == CorpuserUrn.create_from_id("abc")
 | |
| 
 | |
|     def test_invalid_urn(self) -> None:
 | |
|         with self.assertRaises(InvalidUrnError):
 | |
|             CorpuserUrn.create_from_string(
 | |
|                 "urn:li:abc:(urn:li:dataPlatform:abc,def,prod)"
 | |
|             )
 | |
| 
 | |
|         with self.assertRaises(InvalidUrnError):
 | |
|             CorpuserUrn.create_from_string("urn:li:corpuser:(part1,part2)")
 |