Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_execute_mdx_without_columns(self):
# write cube content
self.tm1.cubes.cells.write_values(CUBE_NAME, self.cellset)
# MDX Query that gets full cube content with zero suppression
mdx = MdxBuilder.from_cube(CUBE_NAME) \
.rows_non_empty().add_hierarchy_set_to_row_axis(
MdxHierarchySet.all_members(DIMENSION_NAMES[0], DIMENSION_NAMES[0])) \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.all_members(DIMENSION_NAMES[1], DIMENSION_NAMES[1])) \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.all_members(DIMENSION_NAMES[2], DIMENSION_NAMES[2])) \
.columns_non_empty().add_hierarchy_set_to_column_axis(MdxHierarchySet.from_str("", "", "{}")) \
.to_mdx()
data = self.tm1.cubes.cells.execute_mdx(mdx)
# Check if total value is the same AND coordinates are the same. Handle None
self.assertEqual(self.total_value, sum([v["Value"] for v in data.values() if v["Value"]]))
for coordinates in data.keys():
self.assertEqual(len(coordinates), 3)
self.assertIn("[TM1py_Tests_Cell_Dimension1].", coordinates[0])
self.assertIn("[TM1py_Tests_Cell_Dimension2].", coordinates[1])
self.assertIn("[TM1py_Tests_Cell_Dimension3].", coordinates[2])
def test_execute_mdx_without_rows(self):
# write cube content
self.tm1.cubes.cells.write_values(CUBE_NAME, self.cellset)
mdx = MdxBuilder.from_cube(CUBE_NAME) \
.columns_non_empty() \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.all_members(DIMENSION_NAMES[0], DIMENSION_NAMES[0])) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.all_members(DIMENSION_NAMES[1], DIMENSION_NAMES[1])) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.all_members(DIMENSION_NAMES[2], DIMENSION_NAMES[2])) \
.rows_non_empty() \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.from_str("", "", "{}")) \
.to_mdx()
data = self.tm1.cubes.cells.execute_mdx(mdx)
# Check if total value is the same AND coordinates are the same. Handle None
self.assertEqual(self.total_value, sum([v["Value"] for v in data.values() if v["Value"]]))
for coordinates in data.keys():
self.assertEqual(len(coordinates), 3)
self.assertIn("[TM1py_Tests_Cell_Dimension1].", coordinates[0])
self.assertIn("[TM1py_Tests_Cell_Dimension2].", coordinates[1])
self.assertIn("[TM1py_Tests_Cell_Dimension3].", coordinates[2])