def test_change_include_in_sandbox_dimension_false(self): sandbox = Sandbox("sandbox", True) sandbox.include_in_sandbox_dimension = False self.assertEqual( '{"Name": "sandbox", "IncludeInSandboxDimension": false}', sandbox.body)
def test_change_name(self): sandbox = Sandbox("sandbox", True) sandbox.name = "new sandbox" self.assertEqual( '{"Name": "new sandbox", "IncludeInSandboxDimension": true}', sandbox.body)
def setUp(cls): # Connection to TM1 cls.config = configparser.ConfigParser() cls.config.read(Path(__file__).parent.joinpath('config.ini')) cls.tm1 = TM1Service(**cls.config['tm1srv01']) for dimension_name in cls.dimension_names: elements = [ Element('Element {}'.format(str(j)), 'Numeric') for j in range(1, 1001) ] hierarchy = Hierarchy(dimension_name=dimension_name, name=dimension_name, elements=elements) dimension = Dimension(dimension_name, [hierarchy]) if not cls.tm1.dimensions.exists(dimension.name): cls.tm1.dimensions.create(dimension) # Build Cube cube = Cube(cls.cube_name, cls.dimension_names) if not cls.tm1.cubes.exists(cls.cube_name): cls.tm1.cubes.create(cube) c = Cube(cls.cube_name, dimensions=cls.dimension_names, rules=Rules('')) if cls.tm1.cubes.exists(c.name): cls.tm1.cubes.delete(c.name) cls.tm1.cubes.create(c) if not cls.tm1.sandboxes.exists(cls.sandbox_name1): cls.tm1.sandboxes.create( Sandbox(name=cls.sandbox_name1, include_in_sandbox_dimension=True))
def test_merge_without_clean_after(self): mdx = MdxBuilder.from_cube(self.cube_name).add_member_tuple_to_columns( Member.of(self.dimension_names[0], "Element1"), Member.of(self.dimension_names[1], "Element1"), Member.of(self.dimension_names[2], "Element1")) \ .to_mdx() sandbox2 = Sandbox(self.sandbox_name2, True) self.tm1.sandboxes.create(sandbox2) self.tm1.cells.write_values(cube_name=self.cube_name, cellset_as_dict={ ("Element1", "Element1", "Element1"): 5 }, sandbox_name=self.sandbox_name2) self.tm1.sandboxes.merge(source_sandbox_name=self.sandbox_name2, target_sandbox_name=self.sandbox_name1, clean_after=False) values = self.tm1.cells.execute_mdx_values( mdx=mdx, sandbox_name=self.sandbox_name1) self.assertEqual(5, values[0]) values = self.tm1.cells.execute_mdx_values( mdx=mdx, sandbox_name=self.sandbox_name2) self.assertEqual(5, values[0])
def test_delete_sandbox(self): sandbox2 = Sandbox(self.sandbox_name2, True) self.tm1.sandboxes.create(sandbox2) self.tm1.sandboxes.delete(self.sandbox_name2) exists = self.tm1.sandboxes.exists(sandbox2) self.assertFalse(exists)
def test_get_all(self): sandboxes = self.tm1.sandboxes.get_all() self.assertEqual(1, len(sandboxes)) self.assertEqual(sandboxes[0], Sandbox(self.sandbox_name1, True))
def test_body_include_in_sandbox_dimension_true(self): sandbox = Sandbox("sandbox", True) self.assertEqual( '{"Name": "sandbox", "IncludeInSandboxDimension": true}', sandbox.body)
def test_from_json_include_in_sandbox_dimension_false(self): sandbox = Sandbox.from_json('{"Name": "sandbox", "IncludeInSandboxDimension": true}') self.assertEqual( '{"Name": "sandbox", "IncludeInSandboxDimension": true}', sandbox.body)
def test_from_json_include_in_sandbox_dimension_true(self): sandbox = Sandbox.from_json('{"Name": "sandbox", "IncludeInSandboxDimension": true}') self.assertEqual(sandbox.name, "sandbox") self.assertTrue(sandbox._include_in_sandbox_dimension)