def test_tm1tidy_true_input_view(self): # define input view and output view mdx_input = MDX_TEMPLATE_SHORT.format( rows="{ HEAD ( { [" + DIMENSION_NAMES[0] + "].Members}," + str(len(STDEV_INPUT_VALUES)) + ") }", columns="{[" + DIMENSION_NAMES[1] + "].[Element_1]}", cube=CUBE_NAME_SOURCE) view_input = MDXView(cube_name=CUBE_NAME_SOURCE, view_name=VIEW_NAME_SOURCE, MDX=mdx_input) self.tm1.cubes.views.create(view=view_input, private=False) # write values into input view mdx = view_input.MDX self.tm1.cubes.cells.write_values_through_cellset( mdx, STDEV_INPUT_VALUES) # execute method stdev(tm1_services={"tm1srv01": self.tm1}, tm1_source="tm1srv01", cube_source=CUBE_NAME_SOURCE, view_source=VIEW_NAME_SOURCE, tidy=True) # check existence self.assertFalse( self.tm1.cubes.views.exists(cube_name=CUBE_NAME_SOURCE, view_name=VIEW_NAME_SOURCE, private=False))
def test_tm1tidy_true_input_values_output_view(self): # define output view mdx_output = MDX_TEMPLATE_SHORT.format( rows="{[" + DIMENSION_NAMES[0] + "].[Element_1]}", columns="{[" + DIMENSION_NAMES[1] + "].[Element_1]}", cube=CUBE_NAME_TARGET) view_output = MDXView(cube_name=CUBE_NAME_TARGET, view_name=VIEW_NAME_TARGET, MDX=mdx_output) self.tm1.cubes.views.create(view=view_output, private=False) # execute method stdev(tm1_services={"tm1srv01": self.tm1}, tm1_target="tm1srv01", cube_target=CUBE_NAME_TARGET, view_target=VIEW_NAME_TARGET, values=STDEV_INPUT_VALUES, tidy=True) # check view existence self.assertFalse( self.tm1.cubes.views.exists(cube_name=CUBE_NAME_TARGET, view_name=VIEW_NAME_TARGET, private=False))
def test_tm1io_input_mdx_view_output_mdx_view(self): # create input view mdx_input = MDX_TEMPLATE_SHORT.format( rows="{ HEAD ( { [" + DIMENSION_NAMES[0] + "].Members}," + str(len(STDEV_INPUT_VALUES)) + ") }", columns="{[" + DIMENSION_NAMES[1] + "].[Element_1]}", cube=CUBE_NAME_SOURCE) view_input = MDXView(cube_name=CUBE_NAME_SOURCE, view_name=VIEW_NAME_SOURCE, MDX=mdx_input) self.tm1.cubes.views.create(view=view_input, private=False) # create output view mdx_output = MDX_TEMPLATE_SHORT.format( rows="{[" + DIMENSION_NAMES[0] + "].[Element_1]}", columns="{[" + DIMENSION_NAMES[1] + "].[Element_1]}", cube=CUBE_NAME_TARGET) view_output = MDXView(cube_name=CUBE_NAME_TARGET, view_name=VIEW_NAME_TARGET, MDX=mdx_output) self.tm1.cubes.views.create(view=view_output, private=False) # write values into input view mdx = view_input.MDX self.tm1.cubes.cells.write_values_through_cellset( mdx, STDEV_INPUT_VALUES) # execute method result = stdev(tm1_services={ "tm1srv01": self.tm1, "tm1srv02": self.tm1 }, tm1_source="tm1srv01", tm1_target="tm1srv02", cube_source=CUBE_NAME_SOURCE, cube_target=CUBE_NAME_TARGET, view_source=VIEW_NAME_SOURCE, view_target=VIEW_NAME_TARGET) self.assertAlmostEqual(STDEV_EXPECTED_RESULT, result, delta=STDEV_TOLERANCE) # check output view cell_value = next( self.tm1.cubes.cells.execute_view_values( cube_name=CUBE_NAME_TARGET, view_name=VIEW_NAME_TARGET, private=False)) self.assertAlmostEqual(cell_value, STDEV_EXPECTED_RESULT, delta=STDEV_TOLERANCE)
def test_stdev(self): result = stdev(values=STDEV_INPUT_VALUES) self.assertAlmostEqual(result, STDEV_EXPECTED_RESULT, delta=STDEV_TOLERANCE)