def test_dump(self): opt = {"option1": "value1", "option2": "value2"} storage = Storage("storage1", "redis", opt) storage.dump("storage.yaml") storage2 = Storage.from_yaml("storage.yaml") assert storage.id == storage2.id assert storage.type == storage2.type assert storage.options == storage2.options assert storage2.options == opt #cleanup os.remove("storage.yaml")
def test_apply_multiple(self, client, mocker): my_storage = Storage(id="TEST", type="redis") my_feature_group = FeatureGroup(id="test") my_entity = Entity(name="test") grpc_stub = core.CoreServiceStub(grpc.insecure_channel("")) mocker.patch.object( grpc_stub, 'ApplyStorage', return_value=CoreServiceTypes.ApplyStorageResponse( storageId="TEST")) mocker.patch.object( grpc_stub, 'ApplyFeatureGroup', return_value=CoreServiceTypes.ApplyFeatureGroupResponse( featureGroupId="test")) mocker.patch.object( grpc_stub, 'ApplyEntity', return_value=CoreServiceTypes.ApplyEntityResponse( entityName="test")) client._core_service_stub = grpc_stub ids = client.apply([my_storage, my_entity, my_feature_group]) assert ids == ["TEST", "test", "test"]
def test_from_yaml(self): storage = Storage.from_yaml("tests/sample/valid_storage.yaml") assert storage.id == "BIGQUERY1" assert storage.type == "bigquery" expDict = { "dataset": "feast", "project": "gcp-project", "tempLocation": "gs://feast-storage" } assert storage.options == expDict
def test_apply_single_storage(self, client, mocker): my_storage = Storage(id="TEST", type="redis") grpc_stub = core.CoreServiceStub(grpc.insecure_channel("")) with mocker.patch.object(grpc_stub, 'ApplyStorage', return_value=CoreServiceTypes.ApplyStorageResponse( storageId="TEST")): client._core_service_stub = grpc_stub name = client.apply(my_storage) assert name == "TEST"
def test_update_options(self): storage = Storage(id="storage1", type="redis") assert storage.options == {} myDict = {'key': 'value'} storage.options = myDict assert storage.options == myDict