def METHOD_NAME():
    with instance_for_test() as instance:
        partitions_def = DynamicPartitionsDefinition(name="foo")
        @asset(partitions_def=partitions_def)
        def my_asset():
            return 1
        with pytest.raises(DagsterUnknownPartitionError):
            materialize([my_asset], instance=instance, partition_key="a")
        instance.add_dynamic_partitions("foo", ["a"])
        assert partitions_def.get_partition_keys(dynamic_partitions_store=instance) == ["a"]
        assert materialize([my_asset], instance=instance, partition_key="a").success
        materialization = instance.get_latest_materialization_event(AssetKey("my_asset"))
        assert materialization
        assert materialization.dagster_event.partition == "a"
        with pytest.raises(CheckError):
            partitions_def.get_partition_keys()