Ejemplo n.º 1
0
 def verify(self):
     """
     This mehod will generate expected dict from the data store and
     actual dict is generated from read operation of the task entity
     :return: status
     """
     self.status = True
     self.step_desc = 'Task update verification'
     self.remarks = '\n Inside class: %s method: %s \n' % utils.get_method_class_names(
     )
     data_store = self.request.getfixturevalue('data_store').get()
     expected_dct = data_store[ENTITY][self.task_id]
     title = expected_dct.get('title')
     encoded_title = utils.html_encode(title)
     expected_dct.update({'title': encoded_title})
     if expected_dct.get('description'):
         description = expected_dct.get('description')
         encoded_desc = utils.html_encode(description)
         expected_dct.update({'description': encoded_desc})
     self.step_input = json.dumps(expected_dct)
     response = super().read(entity_id=self.task_id)
     actual_dct = response.json()['data'][0]
     try:
         self.status, remark = self.asserter.verify(
             actual_dct, expected_dct=expected_dct)
         self.remarks += remark
     except KeyError:
         self.status = False
         self.remarks += 'KeyError Exception occurred, please see stack trace below: \n %s' \
                         % traceback.format_exc()
     finally:
         db_wrapper.log_into_steps(self.request, self)
     assert self.status
     return self
Ejemplo n.º 2
0
 def _construct_expected_dct(field, field_data_type, field_value,
                             default_values, display_option):
     lst_fields_accepts_integer = [
         'PROJECT % COMPLETE METHOD *', 'PROJECT ALLOCATION UNITS',
         'PROJECT CONFIDENTIAL PROJECT', 'PROJECT NEW TASKS'
     ]
     if field == 'PORTFOLIO CATEGORY ID *' or field == 'PORTFOLIO CATEGORY ID':
         if field_value == 'Port':
             field_value = 'Port - ' + field_value
         else:
             field_value = 'Portfolio - ' + field_value
     elif field_value is None:
         field_value = ''
     elif field_data_type == 'date':
         date_time = datetime.strptime(field_value, '%m/%d/%Y')
         field_value = date_time.strftime('%Y-%m-%dT00:00:00.000')
     elif field_data_type == 'float':
         # PPMPRO has float rounding to 3 decimal places
         field_value = round(field_value, 3)
     elif field_data_type == 'number' and display_option == 'Percent':
         field_value = field_value / 100
     elif field_data_type == 'boolean' and display_option == 'Yes/No':
         dct_bool_yes_no = {True: 'Yes', False: 'No'}
         field_value = dct_bool_yes_no[field_value]
     elif field in lst_fields_accepts_integer:
         for default_value in default_values:
             if default_value['value'] == field_value:
                 field_value = default_value['displayText']
                 break
     if isinstance(field_value, str):
         field_value = utils.html_encode(field_value)
     return field_value
Ejemplo n.º 3
0
    def verify(self):
        """
        This mehod will generate expected dict from the data store and
        actual dict is generated from read operation of the project entity
        :return: status
        """
        self.status = True
        self.step_desc = 'Project update verification'
        self.remarks = '\n Inside class: %s method: %s \n' % utils.get_method_class_names(
        )
        expected_dct = self.db_store.search_by_key(ENTITY, 'id',
                                                   self.project_id)[0]
        title = expected_dct.get('title')
        encoded_title = utils.html_encode(title)
        expected_dct.update({'title': encoded_title})
        if expected_dct.get('description'):
            description = expected_dct.get('description')
            encoded_desc = utils.html_encode(description)
            expected_dct.update({'description': encoded_desc})
        self.step_input = '\n Expected Dictionary\n{}'.format(
            json.dumps(expected_dct))

        response = super().read(entity_id=self.project_id)
        actual_dct = response.json()['data'][0]
        self.step_input += '\n Actual Dictionary\n{}'.format(
            json.dumps(actual_dct))

        try:
            self.status, remark = self.asserter.verify(
                actual_dct, expected_dct=expected_dct)
            self.remarks += remark
        except KeyError:
            self.status = False
            self.remarks += 'KeyError Exception occurred, please see stack trace below: \n %s' \
                            % traceback.format_exc()
        finally:
            db_wrapper.log_into_steps(self.request, self)
        assert self.status
        return self