コード例 #1
0
ファイル: Annotation.py プロジェクト: cubewise-tryan/TM1py
    def test1_create_annotation(self):
        annotation = Annotation(comment_value=self.random_text,
                                object_name=cube_name,
                                dimensional_context=self.random_intersection)
        response = self.tm1.cubes.annotations.create(annotation)
        annotation_id = json.loads(response)['ID']

        # test, if it exists
        all_annotations = self.tm1.cubes.annotations.get_all(cube_name)
        if len(all_annotations) > 0:
            annotation = self.tm1.cubes.annotations.get(annotation_id)
            self.assertEqual(self.random_text, annotation.comment_value)
コード例 #2
0
    def setUp(cls):
        """
        Run before each test to create a test annotation
        """
        random_intersection = cls.tm1.cubes.get_random_intersection(cls.cube_name, False)
        random_text = "".join([random.choice(string.printable) for _ in range(100)])

        annotation = Annotation(comment_value=random_text,
                                object_name=cls.cube_name,
                                dimensional_context=random_intersection)

        cls.annotation_id = cls.tm1.cubes.annotations.create(annotation).json().get("ID")
コード例 #3
0
ファイル: Annotation.py プロジェクト: swethadc/tm1py
    def create_annotation(cls):
        # create annotations
        random_intersection = cls.tm1.cubes.get_random_intersection(
            cls.cube_name, False)
        random_text = "".join(
            [random.choice(string.printable) for _ in range(100)])

        annotation = Annotation(comment_value=random_text,
                                object_name=cls.cube_name,
                                dimensional_context=random_intersection)
        response = cls.tm1.cubes.annotations.create(annotation)
        annotation_id = response.json()['ID']

        return annotation_id
コード例 #4
0
    def test_create(self):
        """
        Check that an annotation can be created on the server
        Check that created annotation has the correct comment_value
        """
        annotation_count = len(self.tm1.cubes.annotations.get_all(self.cube_name))
        random_intersection = self.tm1.cubes.get_random_intersection(self.cube_name, False)
        random_text = "".join([random.choice(string.printable) for _ in range(100)])

        annotation = Annotation(
            comment_value=random_text,
            object_name=self.cube_name,
            dimensional_context=random_intersection)

        annotation_id = self.tm1.cubes.annotations.create(annotation).json().get("ID")
        all_annotations = self.tm1.cubes.annotations.get_all(self.cube_name)
        self.assertGreater(len(all_annotations), annotation_count)

        new_annotation = self.tm1.cubes.annotations.get(annotation_id)
        self.assertEqual(new_annotation.comment_value, random_text)
コード例 #5
0
from TM1py.Objects import Annotation
from TM1py.Services import TM1Service

config = configparser.ConfigParser()
config.read(r'..\config.ini')

# connection to TM1 Server
tm1 = TM1Service(**config['tm1srv01'])

# just a random text
random_string = str(uuid.uuid4())

# create instance of TM1py.Annotation
a = Annotation(comment_value=random_string,
               object_name='plan_BudgetPlan',
               dimensional_context=[
                   'FY 2004 Forecast', '10110', '110', '61065', 'planning',
                   'revenue (future)', 'Jan-2005'
               ])

# create annotation on TM1 Server
tm1.cubes.annotations.create(a)

# find the created annotation and delete it
for annotation in tm1.cubes.annotations.get_all('plan_BudgetPlan'):
    if annotation.comment_value == random_string:
        tm1.cubes.annotations.delete(annotation_id=annotation.id)

# logout
tm1.logout()