-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
774d161
commit 6c38897
Showing
1 changed file
with
13 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
import sempy.fabric | ||
from unittest.mock import patch | ||
from sempy_labs.tom import connect_semantic_model | ||
from sempy_labs._helper_functions import resolve_workspace_name_and_id | ||
|
||
|
||
@patch("sempy.fabric.resolve_item_id") | ||
@patch("sempy.fabric.resolve_workspace_id") | ||
@patch("sempy_labs._helper_functions.resolve_dataset_name_and_id") | ||
@patch("sempy_labs._helper_functions.resolve_workspace_name_and_id") | ||
@patch("sempy.fabric.create_tom_server") | ||
def test_tom_wrapper(create_tom_server): | ||
def test_tom_wrapper(create_tom_server, resolve_workspace_name_and_id, resolve_dataset_name_and_id, resolve_workspace_id, resolve_item_id): | ||
|
||
sempy.fabric._client._utils._init_analysis_services() | ||
import Microsoft.AnalysisServices.Tabular as TOM | ||
|
||
resolve_workspace_name_and_id.return_value = ("my_workspace", "my_workspace_id") | ||
resolve_dataset_name_and_id.return_value = ("my_dataset", "my_dataset_id") | ||
resolve_workspace_id.return_value = "my_workspace_id" | ||
resolve_item_id.return_value = "my_dataset_id" | ||
|
||
# create dummy server, database and model | ||
tom_server = TOM.Server() | ||
|
||
db = TOM.Database() | ||
db.Name = "my_dataset" | ||
db.ID = "my_dataset" | ||
db.ID = "my_dataset_id" | ||
db.Model = TOM.Model() | ||
tom_server.Databases.Add(db) | ||
|
||
create_tom_server.return_value = tom_server | ||
|
||
resolve_workspace_name_and_id.return_value = ("my_workspace", "my_workspace_id") | ||
|
||
# invoke the wrapper | ||
with connect_semantic_model("my_dataset") as tom: | ||
with connect_semantic_model(dataset="my_dataset_id", workspace="my_workspace") as tom: | ||
tom.add_table("my_table") | ||
|
||
# validate the result | ||
assert tom_server.Databases["my_dataset"].Model.Tables["my_table"] is not None | ||
assert tom_server.Databases["my_dataset_id"].Model.Tables["my_table"] is not None |