| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  | import json | 
					
						
							| 
									
										
										
										
											2021-02-11 23:14:20 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | import pytest | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-13 17:30:24 -07:00
										 |  |  | from tests.test_helpers import mce_helpers | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-11 16:00:29 -08:00
										 |  |  | basic_1 = json.loads( | 
					
						
							|  |  |  |     """[
 | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  |     { | 
					
						
							|  |  |  |         "auditHeader": null, | 
					
						
							|  |  |  |         "proposedSnapshot": { | 
					
						
							|  |  |  |             "com.linkedin.pegasus2avro.metadata.snapshot.DatasetSnapshot": { | 
					
						
							|  |  |  |                 "urn": "urn:li:dataset:(urn:li:dataPlatform:kafka,SampleKafkaDataset,PROD)", | 
					
						
							|  |  |  |                 "aspects": [ | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                         "com.linkedin.pegasus2avro.common.Ownership": { | 
					
						
							|  |  |  |                             "owners": [ | 
					
						
							|  |  |  |                                 { | 
					
						
							|  |  |  |                                     "owner": "urn:li:corpuser:jdoe", | 
					
						
							|  |  |  |                                     "type": "DATAOWNER", | 
					
						
							|  |  |  |                                     "source": null | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             ], | 
					
						
							|  |  |  |                             "lastModified": { | 
					
						
							|  |  |  |                                 "time": 1581407189000, | 
					
						
							|  |  |  |                                 "actor": "urn:li:corpuser:jdoe", | 
					
						
							|  |  |  |                                 "impersonator": null | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     }, | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                         "com.linkedin.pegasus2avro.common.InstitutionalMemory": { | 
					
						
							|  |  |  |                             "elements": [ | 
					
						
							|  |  |  |                                 { | 
					
						
							|  |  |  |                                     "url": "https://www.linkedin.com", | 
					
						
							|  |  |  |                                     "description": "Sample doc", | 
					
						
							|  |  |  |                                     "createStamp": { | 
					
						
							|  |  |  |                                         "time": 1581407189000, | 
					
						
							|  |  |  |                                         "actor": "urn:li:corpuser:jdoe", | 
					
						
							|  |  |  |                                         "impersonator": null | 
					
						
							|  |  |  |                                     } | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             ] | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 ] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         "proposedDelta": null | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-11 16:00:29 -08:00
										 |  |  | ]"""
 | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Timestamps changed from basic_1 but same otherwise. | 
					
						
							| 
									
										
										
										
											2021-02-11 16:00:29 -08:00
										 |  |  | basic_2 = json.loads( | 
					
						
							|  |  |  |     """[
 | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  |     { | 
					
						
							|  |  |  |         "auditHeader": null, | 
					
						
							|  |  |  |         "proposedSnapshot": { | 
					
						
							|  |  |  |             "com.linkedin.pegasus2avro.metadata.snapshot.DatasetSnapshot": { | 
					
						
							|  |  |  |                 "urn": "urn:li:dataset:(urn:li:dataPlatform:kafka,SampleKafkaDataset,PROD)", | 
					
						
							|  |  |  |                 "aspects": [ | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                         "com.linkedin.pegasus2avro.common.Ownership": { | 
					
						
							|  |  |  |                             "owners": [ | 
					
						
							|  |  |  |                                 { | 
					
						
							|  |  |  |                                     "owner": "urn:li:corpuser:jdoe", | 
					
						
							|  |  |  |                                     "type": "DATAOWNER", | 
					
						
							|  |  |  |                                     "source": null | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             ], | 
					
						
							|  |  |  |                             "lastModified": { | 
					
						
							|  |  |  |                                 "time": 1581407199000, | 
					
						
							|  |  |  |                                 "actor": "urn:li:corpuser:jdoe", | 
					
						
							|  |  |  |                                 "impersonator": null | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     }, | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                         "com.linkedin.pegasus2avro.common.InstitutionalMemory": { | 
					
						
							|  |  |  |                             "elements": [ | 
					
						
							|  |  |  |                                 { | 
					
						
							|  |  |  |                                     "url": "https://www.linkedin.com", | 
					
						
							|  |  |  |                                     "description": "Sample doc", | 
					
						
							|  |  |  |                                     "createStamp": { | 
					
						
							|  |  |  |                                         "time": 1581407389000, | 
					
						
							|  |  |  |                                         "actor": "urn:li:corpuser:jdoe", | 
					
						
							|  |  |  |                                         "impersonator": null | 
					
						
							|  |  |  |                                     } | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             ] | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 ] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         "proposedDelta": null | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-11 16:00:29 -08:00
										 |  |  | ]"""
 | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Dataset owner changed from basic_2. | 
					
						
							| 
									
										
										
										
											2021-02-11 16:00:29 -08:00
										 |  |  | basic_3 = json.loads( | 
					
						
							|  |  |  |     """[
 | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  |     { | 
					
						
							|  |  |  |         "auditHeader": null, | 
					
						
							|  |  |  |         "proposedSnapshot": { | 
					
						
							|  |  |  |             "com.linkedin.pegasus2avro.metadata.snapshot.DatasetSnapshot": { | 
					
						
							|  |  |  |                 "urn": "urn:li:dataset:(urn:li:dataPlatform:kafka,SampleKafkaDataset,PROD)", | 
					
						
							|  |  |  |                 "aspects": [ | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                         "com.linkedin.pegasus2avro.common.Ownership": { | 
					
						
							|  |  |  |                             "owners": [ | 
					
						
							|  |  |  |                                 { | 
					
						
							|  |  |  |                                     "owner": "urn:li:corpuser:datahub", | 
					
						
							|  |  |  |                                     "type": "DATAOWNER", | 
					
						
							|  |  |  |                                     "source": null | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             ], | 
					
						
							|  |  |  |                             "lastModified": { | 
					
						
							|  |  |  |                                 "time": 1581407199000, | 
					
						
							|  |  |  |                                 "actor": "urn:li:corpuser:jdoe", | 
					
						
							|  |  |  |                                 "impersonator": null | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     }, | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                         "com.linkedin.pegasus2avro.common.InstitutionalMemory": { | 
					
						
							|  |  |  |                             "elements": [ | 
					
						
							|  |  |  |                                 { | 
					
						
							|  |  |  |                                     "url": "https://www.linkedin.com", | 
					
						
							|  |  |  |                                     "description": "Sample doc", | 
					
						
							|  |  |  |                                     "createStamp": { | 
					
						
							|  |  |  |                                         "time": 1581407389000, | 
					
						
							|  |  |  |                                         "actor": "urn:li:corpuser:jdoe", | 
					
						
							|  |  |  |                                         "impersonator": null | 
					
						
							|  |  |  |                                     } | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             ] | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 ] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         "proposedDelta": null | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-11 16:00:29 -08:00
										 |  |  | ]"""
 | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-14 13:40:24 -07:00
										 |  |  | def test_basic_diff_same() -> None: | 
					
						
							| 
									
										
										
										
											2021-06-30 16:53:20 -07:00
										 |  |  |     mce_helpers.assert_mces_equal(basic_1, basic_2, mce_helpers.IGNORE_PATH_TIMESTAMPS) | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-11 16:00:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-14 13:40:24 -07:00
										 |  |  | def test_basic_diff_only_owner_change() -> None: | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  |     with pytest.raises(AssertionError): | 
					
						
							| 
									
										
										
										
											2021-06-30 16:53:20 -07:00
										 |  |  |         mce_helpers.assert_mces_equal( | 
					
						
							|  |  |  |             basic_2, basic_3, mce_helpers.IGNORE_PATH_TIMESTAMPS | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-11 16:00:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-14 13:40:24 -07:00
										 |  |  | def test_basic_diff_owner_change() -> None: | 
					
						
							| 
									
										
										
										
											2021-02-11 12:53:44 -08:00
										 |  |  |     with pytest.raises(AssertionError): | 
					
						
							| 
									
										
										
										
											2021-06-30 16:53:20 -07:00
										 |  |  |         mce_helpers.assert_mces_equal( | 
					
						
							|  |  |  |             basic_1, basic_3, mce_helpers.IGNORE_PATH_TIMESTAMPS | 
					
						
							|  |  |  |         ) |