예제 #1
0
파일: Chore.py 프로젝트: mschlinz/tm1py
    def setUp(cls):
        # create chores
        c1 = Chore(name=CHORE_NAME1,
                   start_time=ChoreStartTime(cls.start_time.year,
                                             cls.start_time.month,
                                             cls.start_time.day,
                                             cls.start_time.hour,
                                             cls.start_time.minute,
                                             cls.start_time.second),
                   dst_sensitivity=False,
                   active=True,
                   execution_mode=Chore.MULTIPLE_COMMIT,
                   frequency=cls.frequency,
                   tasks=cls.tasks)
        cls.tm1.chores.create(c1)

        c2 = Chore(name=CHORE_NAME2,
                   start_time=ChoreStartTime(cls.start_time.year,
                                             cls.start_time.month,
                                             cls.start_time.day,
                                             cls.start_time.hour,
                                             cls.start_time.minute,
                                             cls.start_time.second),
                   dst_sensitivity=False,
                   active=False,
                   execution_mode=Chore.SINGLE_COMMIT,
                   frequency=cls.frequency,
                   tasks=cls.tasks)
        cls.tm1.chores.create(c2)

        # chore without tasks
        c3 = copy.copy(c2)
        c3.name = CHORE_NAME3
        c3.tasks = []
        cls.tm1.chores.create(c3)
예제 #2
0
파일: Chore.py 프로젝트: tomas1pit/TM1py
    def test_01create_chore(self):
        c1 = Chore(name=self.chore_name1,
                   start_time=ChoreStartTime(self.start_time.year,
                                             self.start_time.month,
                                             self.start_time.day,
                                             self.start_time.hour,
                                             self.start_time.minute,
                                             self.start_time.second),
                   dst_sensitivity=False,
                   active=True,
                   execution_mode='MultipleCommit',
                   frequency=self.frequency,
                   tasks=self.tasks)
        # No exceptions -> means test passed
        self.tm1.chores.create(c1)

        c2 = Chore(name=self.chore_name2,
                   start_time=ChoreStartTime(self.start_time.year,
                                             self.start_time.month,
                                             self.start_time.day,
                                             self.start_time.hour,
                                             self.start_time.minute,
                                             self.start_time.second),
                   dst_sensitivity=False,
                   active=False,
                   execution_mode='SingleCommit',
                   frequency=self.frequency,
                   tasks=self.tasks)
        # No exceptions -> means test passed
        self.tm1.chores.create(c2)
예제 #3
0
파일: Chore.py 프로젝트: kathys007/tm1py
 def setUp(cls):
     # create chores
     c1 = Chore(name=CHORE_NAME1,
                start_time=ChoreStartTime(cls.start_time.year,
                                          cls.start_time.month,
                                          cls.start_time.day,
                                          cls.start_time.hour,
                                          cls.start_time.minute,
                                          cls.start_time.second),
                dst_sensitivity=False,
                active=True,
                execution_mode='MultipleCommit',
                frequency=cls.frequency,
                tasks=cls.tasks)
     cls.tm1.chores.create(c1)
     c2 = Chore(name=CHORE_NAME2,
                start_time=ChoreStartTime(cls.start_time.year,
                                          cls.start_time.month,
                                          cls.start_time.day,
                                          cls.start_time.hour,
                                          cls.start_time.minute,
                                          cls.start_time.second),
                dst_sensitivity=False,
                active=False,
                execution_mode='SingleCommit',
                frequency=cls.frequency,
                tasks=cls.tasks)
     # No exceptions -> means test passed
     cls.tm1.chores.create(c2)
예제 #4
0
    def test_create_chore_with_dst_single_commit(self):
        # create chores
        c4 = Chore(name=self.chore_name4,
                   start_time=ChoreStartTime(self.start_time.year,
                                             self.start_time.month,
                                             self.start_time.day,
                                             self.start_time.hour,
                                             self.start_time.minute,
                                             self.start_time.second),
                   dst_sensitivity=True,
                   active=True,
                   execution_mode=Chore.SINGLE_COMMIT,
                   frequency=self.frequency,
                   tasks=self.tasks)
        self.tm1.chores.create(c4)

        c4 = self.tm1.chores.get(self.chore_name4)

        self.assertEqual(c4.start_time.datetime.hour, self.start_time.hour)
        self.assertEqual(c4._start_time._datetime.replace(hour=0),
                         self.start_time.replace(hour=0, microsecond=0))
        self.assertEqual(c4._name, self.chore_name4)
        self.assertEqual(c4.active, True)
        self.assertEqual(c4._dst_sensitivity, True)
        self.assertEqual(c4._execution_mode, Chore.SINGLE_COMMIT)
        self.assertEqual(c4._frequency._days,
                         str(self.frequency_days).zfill(2))
        self.assertEqual(c4._frequency._hours,
                         str(self.frequency_hours).zfill(2))
        self.assertEqual(c4._frequency._minutes,
                         str(self.frequency_minutes).zfill(2))
        self.assertEqual(c4._frequency._seconds,
                         str(self.frequency_seconds).zfill(2))
        for task1, task2 in zip(self.tasks, c4._tasks):
            self.assertEqual(task1, task2)
예제 #5
0
 def get_all(self, **kwargs) -> List[Chore]:
     """ get a List of all Chores
     :return: List of TM1py.Chore
     """
     url = "/api/v1/Chores?$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))"
     response = self._rest.GET(url, **kwargs)
     return [Chore.from_dict(chore_as_dict) for chore_as_dict in response.json()['value']]
예제 #6
0
    def get_all(self):
        """ get a List of all Chores

        :return: List of TM1py.Chore
        """
        request = "/api/v1/Chores?$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))"
        response = self._rest.GET(request)
        response_as_dict = json.loads(response)
        return [Chore.from_dict(chore_as_dict) for chore_as_dict in response_as_dict['value']]
예제 #7
0
 def get(self, chore_name):
     """ Get a chore from the TM1 Server
     :param chore_name:
     :return: instance of TM1py.Chore
     """
     request = "/api/v1/Chores('{}')?$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))" \
         .format(chore_name)
     response = self._rest.GET(request)
     return Chore.from_dict(response.json())
예제 #8
0
 def get(self, chore_name: str, **kwargs) -> Chore:
     """ Get a chore from the TM1 Server
     :param chore_name:
     :return: instance of TM1py.Chore
     """
     url = format_url(
         "/api/v1/Chores('{}')?$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))",
         chore_name)
     response = self._rest.GET(url, **kwargs)
     return Chore.from_dict(response.json())
예제 #9
0
    def search_for_process_name(self, process_name: str,
                                **kwargs) -> List[Chore]:
        """ Return chore details for any/all chores that contain specified process name in tasks

        :param process_name: string, a valid ti process name; spaces will be elimniated
        """
        url = format_url(
            "/api/v1/Chores?$filter=Tasks/any(t: replace(tolower(t/Process/Name), ' ', '') eq '{}')"
            "&$expand=Tasks($expand=*,Chore($select=Name),Process($select=Name))",
            process_name.lower().replace(' ', ''))
        response = self._rest.GET(url, **kwargs)
        return [
            Chore.from_dict(chore_as_dict)
            for chore_as_dict in response.json()['value']
        ]
예제 #10
0
    def search_for_parameter_value(self, parameter_value: str,
                                   **kwargs) -> List[Chore]:
        """ Return chore details for any/all chores that have a specified value set in the chore parameter settings
            *this will NOT check the process parameter default, rather the defined parameter value saved in the chore

        :param parameter_value: string, will search wildcard for string in parameter value using Contains(string)
        """
        url = format_url(
            "/api/v1/Chores?"
            "$filter=Tasks/any(t: t/Parameters/any(p: isof(p/Value, Edm.String) and contains(tolower(p/Value), '{}')))"
            "&$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))",
            parameter_value.lower())
        response = self._rest.GET(url, **kwargs)
        return [
            Chore.from_dict(chore_as_dict)
            for chore_as_dict in response.json()['value']
        ]
예제 #11
0
파일: Chore.py 프로젝트: mschlinz/tm1py
    def test_create_chore_with_dst(self):
        # create chores
        c4 = Chore(name=CHORE_NAME4,
                   start_time=ChoreStartTime(self.start_time.year,
                                             self.start_time.month,
                                             self.start_time.day,
                                             self.start_time.hour,
                                             self.start_time.minute,
                                             self.start_time.second),
                   dst_sensitivity=True,
                   active=True,
                   execution_mode=Chore.MULTIPLE_COMMIT,
                   frequency=self.frequency,
                   tasks=self.tasks)
        self.tm1.chores.create(c4)

        c4 = self.tm1.chores.get(CHORE_NAME4)

        # delta in start time is expected to be <= 1h due to potential DST
        self.assertLessEqual(
            abs(c4.start_time.datetime.hour - self.start_time.hour), 1)
        self.assertEqual(c4._start_time._datetime.replace(hour=0),
                         self.start_time.replace(hour=0, microsecond=0))
        self.assertEqual(c4._name, CHORE_NAME4)
        self.assertEqual(c4.active, True)
        self.assertEqual(c4._dst_sensitivity, True)
        # Fails on TM1 <= 11.7.00002.1.
        self.assertEqual(c4._execution_mode, Chore.MULTIPLE_COMMIT)
        self.assertEqual(c4._frequency._days,
                         str(self.frequency_days).zfill(2))
        self.assertEqual(c4._frequency._hours,
                         str(self.frequency_hours).zfill(2))
        self.assertEqual(c4._frequency._minutes,
                         str(self.frequency_minutes).zfill(2))
        self.assertEqual(c4._frequency._seconds,
                         str(self.frequency_seconds).zfill(2))
        for task1, task2 in zip(self.tasks, c4._tasks):
            self.assertEqual(task1, task2)
예제 #12
0
from TM1py.Objects import ChoreTask
from TM1py.Services import TM1Service

# connection to TM1 Server
with TM1Service(address='localhost',
                port=12354,
                user='******',
                password='******',
                ssl=True) as tm1:
    now = datetime.now()
    frequency = ChoreFrequency(days='7', hours='9', minutes='2', seconds='45')
    tasks = [
        ChoreTask(0,
                  'import_actuals',
                  parameters=[{
                      'Name': 'pRegion',
                      'Value': 'UK'
                  }])
    ]
    # create an instance of TM1py.Objects.Chore in python
    c = Chore(name='TM1py_' + str(uuid.uuid4()),
              start_time=ChoreStartTime(now.year, now.month, now.day, now.hour,
                                        now.minute, now.second),
              dst_sensitivity=False,
              active=True,
              execution_mode='SingleCommit',
              frequency=frequency,
              tasks=tasks)
    # create the new chore in TM1
    tm1.chores.create(c)