Exemple #1
0
 def test_execute_with_return_success(self):
     process = Utils.load_bedrock_from_github("Bedrock.Server.Wait")
     if not self.tm1.processes.exists(process.name):
         self.tm1.processes.create(process)
     # with parameters
     success, status, error_log_file = self.tm1.processes.execute_with_return(
         process_name=process.name,
         pWaitSec=2)
     self.assertTrue(success)
     self.assertEqual(status, "CompletedSuccessfully")
     self.assertIsNone(error_log_file)
     # without parameters
     success, status, error_log_file = self.tm1.processes.execute_with_return(
         process_name=process.name)
     self.assertTrue(success)
     self.assertEqual(status, "CompletedSuccessfully")
     self.assertIsNone(error_log_file)
Exemple #2
0
    def test_execute_process(self):
        process = Utils.load_bedrock_from_github("Bedrock.Server.Wait")
        if not self.tm1.processes.exists(process.name):
            self.tm1.processes.create(process)

        # with parameters argument
        start_time = time.time()
        self.tm1.processes.execute(process.name, parameters={"Parameters": [
            {"Name": "pWaitSec", "Value": "3"}]})
        elapsed_time = time.time() - start_time
        self.assertGreater(elapsed_time, 3)

        # with kwargs
        start_time = time.time()
        self.tm1.processes.execute(process.name, pWaitSec="1")
        elapsed_time = time.time() - start_time
        self.assertGreater(elapsed_time, 1)

        # without arguments
        self.tm1.processes.execute(process.name)
Exemple #3
0
 def test_delete_process(self):
     process = Utils.load_bedrock_from_github("Bedrock.Server.Wait")
     process.name = str(uuid.uuid4())
     if not self.tm1.processes.exists(process.name):
         self.tm1.processes.create(process)
     self.tm1.processes.delete(process.name)
Exemple #4
0
    def setUpClass(cls):
        # Namings
        cls.expand_process_name = str(uuid.uuid4())
        cls.expand_process_name_obf = str(uuid.uuid4())
        cls.process_name = str(uuid.uuid4())
        cls.process_name_obf = str(uuid.uuid4())
        cls.dimension_name = str(uuid.uuid4())
        cls.dimension_name_cloned = str(uuid.uuid4())
        cls.cube_name = str(uuid.uuid4())
        cls.cube_name_cloned = str(uuid.uuid4())

        # Connect to TM1
        cls.tm1 = TM1Service(**config['tm1srv01'])

        # create process
        prolog = "\r\nSaveDataAll;\r\nsText='abcABC';\r\n"
        epilog = "SaveDataAll;"
        cls.process = Process(name=cls.process_name,
                              prolog_procedure=prolog,
                              epilog_procedure=epilog)
        # create process with expand in TM1
        if cls.tm1.processes.exists(cls.process.name):
            cls.tm1.processes.delete(cls.process.name)
        cls.tm1.processes.create(cls.process)

        # create process with expand
        prolog = "\r\nnRevenue = 20;\r\nsRevenue = EXPAND('%nrevenue%');\r\nIF(sRevenue @ <> '20.000');\r\n" \
                 "ProcessBreak;\r\nENDIF;"
        cls.expand_process = Process(name=cls.expand_process_name,
                                     prolog_procedure=prolog)
        # create process with expand in TM1
        if cls.tm1.processes.exists(cls.expand_process.name):
            cls.tm1.processes.delete(cls.expand_process.name)
        cls.tm1.processes.create(cls.expand_process)

        # create dimension that we clone through obfuscated bedrock as part of the test
        if not cls.tm1.dimensions.exists(cls.dimension_name):
            d = Dimension(cls.dimension_name)
            h = Hierarchy(cls.dimension_name, cls.dimension_name)
            h.add_element('Total Years', 'Consolidated')
            h.add_element('No Year', 'Numeric')
            for year in range(1989, 2040, 1):
                h.add_element(str(year), 'Numeric')
                h.add_edge('Total Years', str(year), 1)
            d.add_hierarchy(h)
            cls.tm1.dimensions.create(d)

            # Create 2 Attributes through TI
            ti_statements = [
                "AttrInsert('{}','','Previous Year', 'S')".format(
                    cls.dimension_name),
                "AttrInsert('{}','','Next Year', 'S');".format(
                    cls.dimension_name)
            ]
            ti = ';'.join(ti_statements)
            cls.tm1.processes.execute_ti_code(lines_prolog=ti)

        # create }ElementAttribute values
        cellset = {}
        for year in range(1989, 2040, 1):
            cellset[(str(year), 'Previous Year')] = year - 1
            cellset[(str(year), 'Next Year')] = year + 1
        cls.tm1.cubes.cells.write_values(
            "}ElementAttributes_" + cls.dimension_name, cellset)

        # create a simple cube to be cloned through bedrock
        if not cls.tm1.cubes.exists(cls.cube_name):
            cube = Cube(cls.cube_name, ["}Dimensions", "}Cubes"],
                        "[]=S:'TM1py';")
            cls.tm1.cubes.create(cube)

        # create bedrocks if they doesn't exist
        for bedrock in ("Bedrock.Dim.Clone", "Bedrock.Cube.Clone"):
            if not cls.tm1.processes.exists(bedrock):
                process = Utils.load_bedrock_from_github(bedrock)
                cls.tm1.processes.create(process)