Esempio n. 1
0
 def setUpClass(self):
     super(Debugreports, self).setUpClass()
     self.validator = Validator(self.logging)
     self.logging = self.session.logging
Esempio n. 2
0
class Debugreports(TestBase):

    """
    Represents test case that could help in testing the REST API supported for Debug Reports.

    Attributes:
    \param TestBase
    config file which contains all configuration information with sections
    """
    default_debugreport_schema = {"type": "object",
                                  "properties": {"name": {"type": "string"},
                                                 "time": {"type": "string"},
                                                 "name": {"type": "string"},
                                                 "uri": {"type": "string"}
                                                 }
                                  }

    default_task_schema = {"type": "object",
                           "properties": {"status": {"type": "string"},
                                          "message": {"type": "string"},
                                          "id": {"type": "string"},
                                          "target_uri": {"type": "string"},
                                          }
                           }

    new_debug_report = {"name": 'test1'}
    debugreport_uri = '/plugins/gingerbase/debugreports'
    rename_reportname = {"name": 'test1_rename'}
    task_uri = '/plugins/gingerbase/tasks'

    @classmethod
    def setUpClass(self):
        super(Debugreports, self).setUpClass()
        self.validator = Validator(self.logging)
        self.logging = self.session.logging

    def test_S001_create_debug_report(self):
        """
        Create new debug report
        """
        self.logging.info('--> Debugreports.test_S001_create_debug_report()')
        try:
            resp_report = self.session.request_post_json(
                Debugreports.debugreport_uri, Debugreports.new_debug_report)
            if resp_report is not None:
                self.logging.debug(
                    'Addition of new repository is successful: %s' % (resp_report))
                self.validator.validate_json(
                    resp_report, Debugreports.default_task_schema)
                self.logging.debug(
                    "**********Debug Report status: \"%s\"" % (resp_report["status"]))
                task_status = resp_report["status"]
                task_id = resp_report["id"]
                while task_status == "running":
                    time.sleep(5)
                    task_resp = self.session.request_get_json(
                        Debugreports.task_uri + '/' + task_id)
                    task_status = task_resp["status"]
                    print "Status: %s" % (task_status)
                    continue
                if task_status == "finished":
                    self.logging.debug('Creation of a debug report is successful: %s' % (
                        Debugreports.new_debug_report["name"]))
                else:
                    self.logging.error('Creation of a debug report is failed')
        except Exception, err:
            self.logging.error(
                'Debugreports.test_S001_create_debug_report(): ERROR: %s\n' % str(err))
            raise Exception(str(err))
        finally:
Esempio n. 3
0
 def setUpClass(self):
     super(Debugreports, self).setUpClass()
     self.validator = Validator()