@@ -1767,3 +1767,92 @@ def test_apply_entity_success_with_purge_feast_metadata(test_registry):
1767
1767
assert len (entities ) == 0
1768
1768
1769
1769
test_registry .teardown ()
1770
+
1771
+
1772
+ combined_sql_fixtures = [
1773
+ pytest .param (
1774
+ lazy_fixture ("pg_registry" ), marks = pytest .mark .xdist_group (name = "pg_registry" )
1775
+ ),
1776
+ pytest .param (
1777
+ lazy_fixture ("mysql_registry" ),
1778
+ marks = pytest .mark .xdist_group (name = "mysql_registry" ),
1779
+ ),
1780
+ lazy_fixture ("sqlite_registry" ),
1781
+ pytest .param (
1782
+ lazy_fixture ("pg_registry_async" ),
1783
+ marks = pytest .mark .xdist_group (name = "pg_registry" ),
1784
+ ),
1785
+ pytest .param (
1786
+ lazy_fixture ("mysql_registry_async" ),
1787
+ marks = pytest .mark .xdist_group (name = "mysql_registry" ),
1788
+ ),
1789
+ pytest .param (
1790
+ lazy_fixture ("pg_registry_purge_feast_metadata" ),
1791
+ marks = pytest .mark .xdist_group (name = "pg_registry" ),
1792
+ ),
1793
+ pytest .param (
1794
+ lazy_fixture ("mysql_registry_purge_feast_metadata" ),
1795
+ marks = pytest .mark .xdist_group (name = "mysql_registry" ),
1796
+ ),
1797
+ ]
1798
+
1799
+
1800
+ @pytest .mark .integration
1801
+ @pytest .mark .parametrize (
1802
+ "test_registry" ,
1803
+ combined_sql_fixtures ,
1804
+ )
1805
+ def test_apply_entity_to_sql_registry_and_reinitialize_sql_registry (test_registry ):
1806
+ entity = Entity (
1807
+ name = "driver_car_id" ,
1808
+ description = "Car driver id" ,
1809
+ tags = {"team" : "matchmaking" },
1810
+ )
1811
+
1812
+ project = "project"
1813
+
1814
+ # Register Entity
1815
+ test_registry .apply_entity (entity , project )
1816
+ assert_project (project , test_registry )
1817
+
1818
+ entities = test_registry .list_entities (project , tags = entity .tags )
1819
+ assert_project (project , test_registry )
1820
+
1821
+ entity = entities [0 ]
1822
+ assert (
1823
+ len (entities ) == 1
1824
+ and entity .name == "driver_car_id"
1825
+ and entity .description == "Car driver id"
1826
+ and "team" in entity .tags
1827
+ and entity .tags ["team" ] == "matchmaking"
1828
+ )
1829
+
1830
+ entity = test_registry .get_entity ("driver_car_id" , project )
1831
+ assert (
1832
+ entity .name == "driver_car_id"
1833
+ and entity .description == "Car driver id"
1834
+ and "team" in entity .tags
1835
+ and entity .tags ["team" ] == "matchmaking"
1836
+ )
1837
+
1838
+ # After the first apply, the created_timestamp should be the same as the last_update_timestamp.
1839
+ assert entity .created_timestamp == entity .last_updated_timestamp
1840
+ updated_test_registry = SqlRegistry (test_registry .registry_config , "project" , None )
1841
+
1842
+ # Update entity
1843
+ updated_entity = Entity (
1844
+ name = "driver_car_id" ,
1845
+ description = "Car driver Id" ,
1846
+ tags = {"team" : "matchmaking" },
1847
+ )
1848
+ updated_test_registry .apply_entity (updated_entity , project )
1849
+
1850
+ updated_entity = updated_test_registry .get_entity ("driver_car_id" , project )
1851
+ updated_test_registry .delete_entity ("driver_car_id" , project )
1852
+ assert_project (project , updated_test_registry )
1853
+ entities = updated_test_registry .list_entities (project )
1854
+ assert_project (project , updated_test_registry )
1855
+ assert len (entities ) == 0
1856
+
1857
+ updated_test_registry .teardown ()
1858
+ test_registry .teardown ()
0 commit comments