-
Notifications
You must be signed in to change notification settings - Fork 118
(Enhancement Proposal) alias infromation from MDX View #1254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9800ed5
b03cb57
1e4a8ce
9b5f214
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import unittest | ||
|
||
from TM1py import MDXView | ||
from unittest.mock import Mock, patch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In TM1py, we don't use mocks for tests. But the benefit of using real API interaction is that we can use the same test suite against different versions of TM1 (e.g. TM1 11 local, PAoC, PAaaS). |
||
from TM1py import ViewService | ||
import json | ||
|
||
|
||
class TestMDXView(unittest.TestCase): | ||
|
@@ -13,6 +16,8 @@ class TestMDXView(unittest.TestCase): | |
FROM [c1] | ||
WHERE ([d3].[d3].[e1], [d4].[e1], [d5].[h1].[e1]) | ||
""" | ||
|
||
rest_response = '''{"@odata.context":"../$metadata#Cubes(\'Cube\')/Views/ibm.tm1.api.v1.MDXView(Cube,LocalizedAttributes)/$entity","@odata.type":"#ibm.tm1.api.v1.MDXView","Name":"MDX View","Attributes":{"Caption":"MDX View"},"MDX":"SELECT {[Dim B].[Dim B].Members} PROPERTIES [Dim B].[Dim B].[Description B] ON COLUMNS , {[Dim A].[Dim A].Members} PROPERTIES [Dim A].[Dim A].[Description] ON ROWS FROM [Cube] ","Cube":{"Name":"Cube","Rules":null,"DrillthroughRules":null,"LastSchemaUpdate":"2025-07-26T10:53:18.870Z","LastDataUpdate":"2025-07-26T10:53:18.870Z","Attributes":{"Caption":"Cube"}},"LocalizedAttributes":[],"FormatString":"0.#########"\n,"Meta":{"Aliases":{"[Dim A].[Dim A]":"Description","[Dim B].[Dim B]":"Description B"},"ContextSets":{},"ExpandAboves":{}}\n}''' | ||
Cubewise-JoeCHK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def setUp(self) -> None: | ||
self.view = MDXView( | ||
|
@@ -68,3 +73,20 @@ def test_substitute_title_value_error(self): | |
with self.assertRaises(ValueError) as error: | ||
self.view.substitute_title(dimension="d6", hierarchy="d6", element="e2") | ||
print(error) | ||
|
||
@patch('TM1py.Services.RestService.RestService') | ||
def test_get_with_retrieving_meta_from_response(self, mock_rest): | ||
mock_response_dict = json.loads(self.rest_response) | ||
mock_response = Mock() | ||
mock_response.json.return_value = mock_response_dict | ||
mock_rest.GET.return_value = mock_response | ||
|
||
service = ViewService(mock_rest) | ||
view = service.get('Cube', 'MDX View', private=False) | ||
self.assertIsInstance(view, MDXView) | ||
self.assertDictEqual(view.aliases, {"Dim A": "Description", "Dim B": "Description B"}) | ||
|
||
def test_from_json_with_Meta_key(self): | ||
view = MDXView.from_json(view_as_json=self.rest_response, cube_name='Cube') | ||
self.assertIsInstance(view, MDXView) | ||
self.assertDictEqual(view.aliases, {"Dim A": "Description", "Dim B": "Description B"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this
alias_by_dimension
and then we need a separate one foralias_by_hierarchy