Пример #1
0
class TestCaseCreate(TestCaseBase):
    @executor.create(httplib.BAD_REQUEST, message.no_body())
    def test_noBody(self):
        return None

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noProject(self):
        self.project = 'noProject'
        return self.req_d

    @executor.create(httplib.BAD_REQUEST, message.missing('name'))
    def test_emptyName(self):
        req_empty = tcm.TestcaseCreateRequest('')
        return req_empty

    @executor.create(httplib.BAD_REQUEST, message.missing('name'))
    def test_noneName(self):
        req_none = tcm.TestcaseCreateRequest(None)
        return req_none

    @executor.create(httplib.OK, '_assert_success')
    def test_success(self):
        return self.req_d

    def _assert_success(self, body):
        self.assert_create_body(body, self.req_d, self.project)

    @executor.create(httplib.FORBIDDEN, message.exist_base)
    def test_alreadyExist(self):
        self.create_d()
        return self.req_d
Пример #2
0
class TestProjectCreate(TestProjectBase):

    @executor.create(httplib.BAD_REQUEST, message.not_login())
    def test_notlogin(self):
        return self.req_d

    @executor.mock_valid_lfid()
    @executor.create(httplib.BAD_REQUEST, message.no_body())
    def test_withoutBody(self):
        return None

    @executor.mock_valid_lfid()
    @executor.create(httplib.BAD_REQUEST, message.missing('name'))
    def test_emptyName(self):
        return project_models.ProjectCreateRequest('')

    @executor.mock_valid_lfid()
    @executor.create(httplib.BAD_REQUEST, message.missing('name'))
    def test_noneName(self):
        return project_models.ProjectCreateRequest(None)

    @executor.mock_valid_lfid()
    @executor.create(httplib.OK, 'assert_create_body')
    def test_success(self):
        return self.req_d

    @executor.mock_valid_lfid()
    @executor.create(httplib.FORBIDDEN, message.exist_base)
    def test_alreadyExist(self):
        self.create_d()
        return self.req_d
Пример #3
0
class TestResultCreate(TestResultBase):
    @executor.create(httplib.BAD_REQUEST, message.no_body())
    def test_nobody(self):
        return None

    @executor.create(httplib.BAD_REQUEST, message.missing('pod_name'))
    def test_podNotProvided(self):
        req = self.req_d
        req.pod_name = None
        return req

    @executor.create(httplib.BAD_REQUEST, message.missing('project_name'))
    def test_projectNotProvided(self):
        req = self.req_d
        req.project_name = None
        return req

    @executor.create(httplib.BAD_REQUEST, message.missing('case_name'))
    def test_testcaseNotProvided(self):
        req = self.req_d
        req.case_name = None
        return req

    @executor.create(httplib.BAD_REQUEST,
                     message.invalid_value('criteria', ['PASS', 'FAIL']))
    def test_invalid_criteria(self):
        req = self.req_d
        req.criteria = 'invalid'
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noPod(self):
        req = self.req_d
        req.pod_name = 'notExistPod'
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noProject(self):
        req = self.req_d
        req.project_name = 'notExistProject'
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noTestcase(self):
        req = self.req_d
        req.case_name = 'notExistTestcase'
        return req

    @executor.create(httplib.OK, 'assert_href')
    def test_success(self):
        return self.req_d

    @executor.create(httplib.OK, 'assert_href')
    def test_key_with_doc(self):
        req = copy.deepcopy(self.req_d)
        req.details = {'1.name': 'dot_name'}
        return req
Пример #4
0
    def _create(self, miss_checks, db_checks, **kwargs):
        """
        :param miss_checks: [miss1, miss2]
        :param db_checks: [(table, exist, query, error)]
        """
        if self.json_args is None:
            raises.BadRequest(message.no_body())

        data = self.table_cls.from_dict(self.json_args)
        for miss in miss_checks:
            miss_data = data.__getattribute__(miss)
            if miss_data is None or miss_data == '':
                raises.BadRequest(message.missing(miss))

        for k, v in kwargs.iteritems():
            data.__setattr__(k, v)

        for table, exist, query, error in db_checks:
            check = yield self._eval_db_find_one(query(data), table)
            if (exist and not check) or (not exist and check):
                code, msg = error(data)
                raises.CodeTBD(code, msg)

        if self.table != 'results':
            data.creation_date = datetime.now()
        _id = yield self._eval_db(self.table,
                                  'insert',
                                  data.format(),
                                  check_keys=False)
        if 'name' in self.json_args:
            resource = data.name
        else:
            resource = _id
        self.finish_request(self._create_response(resource))
Пример #5
0
 def wrap(self, *args, **kwargs):
     fields = kwargs.pop('miss_fields', [])
     if fields:
         for miss in fields:
             miss_data = self.json_args.get(miss)
             if miss_data is None or miss_data == '':
                 raises.BadRequest(message.missing(miss))
     ret = yield gen.coroutine(xstep)(self, *args, **kwargs)
     raise gen.Return(ret)
Пример #6
0
class TestPodCreate(TestPodBase):
    @executor.create(httplib.BAD_REQUEST, message.not_login())
    def test_notlogin(self):
        return self.req_d

    @executor.mock_invalid_lfid()
    @executor.create(httplib.BAD_REQUEST, message.not_lfid())
    def test_invalidLfid(self):
        return self.req_d

    @executor.mock_valid_lfid()
    @executor.create(httplib.BAD_REQUEST, message.no_body())
    def test_withoutBody(self):
        return None

    @executor.mock_valid_lfid()
    @executor.create(httplib.BAD_REQUEST, message.missing('name'))
    def test_emptyName(self):
        return pod_models.PodCreateRequest('')

    @executor.mock_valid_lfid()
    @executor.create(httplib.BAD_REQUEST, message.missing('name'))
    def test_noneName(self):
        return pod_models.PodCreateRequest(None)

    @executor.mock_valid_lfid()
    @executor.create(httplib.OK, 'assert_create_body')
    def test_success(self):
        return self.req_d

    @executor.mock_valid_lfid()
    @executor.create(httplib.FORBIDDEN, message.exist_base)
    def test_alreadyExist(self):
        fake_pymongo.pods.insert(self.pod_d.format())
        return self.req_d

    @executor.mock_valid_lfid()
    @executor.create(httplib.FORBIDDEN, message.exist_base)
    def test_alreadyExistCaseInsensitive(self):
        fake_pymongo.pods.insert(self.pod_d.format())
        self.req_d.name = self.req_d.name.upper()
        return self.req_d
class DeployResultCreate(DeployResultBase):
    @executor.create(httplib.BAD_REQUEST, message.no_body())
    def test_nobody(self):
        return None

    @executor.create(httplib.BAD_REQUEST, message.missing('pod_name'))
    def test_podNotProvided(self):
        req = self.req_d
        req.pod_name = None
        return req

    @executor.create(httplib.BAD_REQUEST, message.missing('installer'))
    def test_installerNotProvided(self):
        req = self.req_d
        req.installer = None
        return req

    @executor.create(httplib.BAD_REQUEST, message.missing('scenario'))
    def test_testcaseNotProvided(self):
        req = self.req_d
        req.scenario = None
        return req

    @executor.create(httplib.BAD_REQUEST,
                     message.invalid_value('criteria', ['PASS', 'FAIL']))
    def test_invalid_criteria(self):
        req = self.req_d
        req.criteria = 'invalid'
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noPod(self):
        req = self.req_d
        req.pod_name = 'notExistPod'
        return req

    @executor.create(httplib.OK, 'assert_href')
    def test_success(self):
        return self.req_d
Пример #8
0
 def test_testcaseNotProvided(self):
     req = self.req_d
     req.case_name = None
     (code, body) = self.create(req)
     self.assertEqual(code, httplib.BAD_REQUEST)
     self.assertIn(message.missing('case_name'), body)
Пример #9
0
class TestResultCreate(TestResultBase):
    @executor.create(httplib.BAD_REQUEST, message.no_body())
    def test_nobody(self):
        return None

    @executor.create(httplib.BAD_REQUEST, message.missing('pod_name'))
    def test_podNotProvided(self):
        req = self.req_d
        req.pod_name = None
        return req

    @executor.create(httplib.BAD_REQUEST, message.missing('project_name'))
    def test_projectNotProvided(self):
        req = self.req_d
        req.project_name = None
        return req

    @executor.create(httplib.BAD_REQUEST, message.missing('case_name'))
    def test_testcaseNotProvided(self):
        req = self.req_d
        req.case_name = None
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noPod(self):
        req = self.req_d
        req.pod_name = 'notExistPod'
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noProject(self):
        req = self.req_d
        req.project_name = 'notExistProject'
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noTestcase(self):
        req = self.req_d
        req.case_name = 'notExistTestcase'
        return req

    @executor.create(httplib.OK, 'assert_href')
    def test_success(self):
        return self.req_d

    @executor.create(httplib.OK, 'assert_href')
    def test_key_with_doc(self):
        req = copy.deepcopy(self.req_d)
        req.details = {'1.name': 'dot_name'}
        return req

    @executor.create(httplib.OK, '_assert_no_ti')
    def test_no_ti(self):
        req = result_models.ResultCreateRequest(pod_name=self.pod,
                                                project_name=self.project,
                                                case_name=self.case,
                                                installer=self.installer,
                                                version=self.version,
                                                start_date=self.start_date,
                                                stop_date=self.stop_date,
                                                details=self.details.format(),
                                                build_tag=self.build_tag,
                                                scenario=self.scenario,
                                                criteria=self.criteria)
        self.actual_req = req
        return req

    def _assert_no_ti(self, body):
        _id = body.href.split('/')[-1]
        code, body = self.get(_id)
        self.assert_res(body, self.actual_req)
Пример #10
0
 def test_noneName(self):
     req_none = models.ScenarioCreateRequest(None)
     (code, body) = self.create(req_none)
     self.assertEqual(code, httplib.BAD_REQUEST)
     self.assertIn(message.missing('name'), body)
Пример #11
0
 def test_noneName(self):
     req_none = testcase_models.TestcaseCreateRequest(None)
     (code, body) = self.create(req_none, self.project)
     self.assertEqual(code, httplib.BAD_REQUEST)
     self.assertIn(message.missing('name'), body)
Пример #12
0
 def test_emptyName(self):
     req_empty = pod_models.PodCreateRequest('')
     (code, body) = self.create(req_empty)
     self.assertEqual(code, httplib.BAD_REQUEST)
     self.assertIn(message.missing('name'), body)
 def _update_requests_rename(self, data):
     data.name = self._term.get('name')
     if not data.name:
         raises.BadRequest(message.missing('name'))
Пример #14
0
class TestResultCreate(TestResultBase):
    @executor.create(httplib.BAD_REQUEST, message.no_body())
    def test_nobody(self):
        return None

    @executor.create(httplib.BAD_REQUEST, message.missing('pod_name'))
    def test_podNotProvided(self):
        req = self.req_d
        req.pod_name = None
        return req

    @executor.create(httplib.BAD_REQUEST, message.missing('project_name'))
    def test_projectNotProvided(self):
        req = self.req_d
        req.project_name = None
        return req

    @executor.create(httplib.BAD_REQUEST, message.missing('case_name'))
    def test_testcaseNotProvided(self):
        req = self.req_d
        req.case_name = None
        return req

    @executor.create(httplib.BAD_REQUEST,
                     message.invalid_value('criteria', ['PASS', 'FAIL']))
    def test_invalid_criteria(self):
        req = self.req_d
        req.criteria = 'invalid'
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noPod(self):
        req = self.req_d
        req.pod_name = 'notExistPod'
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noProject(self):
        req = self.req_d
        req.project_name = 'notExistProject'
        return req

    @executor.create(httplib.FORBIDDEN, message.not_found_base)
    def test_noTestcase(self):
        req = self.req_d
        req.case_name = 'notExistTestcase'
        return req

    @executor.create(httplib.OK, 'assert_href')
    def test_success(self):
        return self.req_d

    @executor.create(httplib.OK, 'assert_href')
    def test_key_with_doc(self):
        req = copy.deepcopy(self.req_d)
        req.details = {'1.name': 'dot_name'}
        return req

    @executor.create(httplib.OK, '_assert_no_ti')
    def test_no_ti(self):
        req = copy.deepcopy(self.req_d)
        req.trust_indicator = rm.TI(0)
        self.actual_req = req
        return req

    def _assert_no_ti(self, body):
        _id = body.href.split('/')[-1]
        code, body = self.get(_id)
        self.assert_res(body, self.actual_req)