Exemplo n.º 1
0
 def get_all(self):
     list = []
     data = Test.query.filter(Test.tenantId == self.auth_context.tenant_id)
     for data_item in data:
         data = data_item.wrap()
         clean_nonserializable_attributes(data)
         list.append(data)
     return list
Exemplo n.º 2
0
    def find_by_id(self, entity_id):
        # filter with id not working,
        # unable to proceed with tenant filter
        data = kate4.query.get(entity_id)
        if data is None:
            raise kate4ServiceError('kate4 {} not found'.format(entity_id),
                                    ErrorCodes.NOT_FOUND)

        data = data.wrap()
        clean_nonserializable_attributes(data)
        return data
Exemplo n.º 3
0
 def test_get_friday_demo_item(self, *args, **kwargs):
     id_to_get = str(self.data.mongo_id)
     rv = self.test_client.get(HELLO_WITH_ID.format(id_to_get),
                               headers=self.headers)
     result = json.loads(rv.data.decode('utf-8'))
     self.assertTrue(rv._status_code == 200)
     self.assertTrue(id_to_get == result['id'])
     get_record_dic = self.data.wrap()
     clean_nonserializable_attributes(get_record_dic)
     for key in get_record_dic:
         self.assertEqual(get_record_dic[key], result.get(key),
                          "assertion failed for key {} ".format(key))
Exemplo n.º 4
0
    def get_all(self, project_id, iteration_id):
        list = []
        data = Artifacts.query.filter(
            Artifacts.orgId == self.auth_context.org_id,
            Artifacts.projectId == project_id,
            Artifacts.iterationId == iteration_id).all()

        for data_item in data:
            data = data_item.wrap()
            clean_nonserializable_attributes(data)
            list.append(data)
        return list
Exemplo n.º 5
0
 def test_get_friday_demo(self, *args, **kwargs):
     id_to_get = str(self.data.mongo_id)
     rv = self.test_client.get(HELLO, headers=self.headers)
     result_collection = json.loads(rv.data.decode('utf-8'))
     self.assertTrue(rv._status_code == 200,
                     "got status code " + str(rv.status_code))
     self.assertTrue(len(result_collection) == 1)
     self.assertTrue(result_collection[0].get('id') == id_to_get)
     get_record_dic = self.data.wrap()
     clean_nonserializable_attributes(get_record_dic)
     for key in get_record_dic:
         self.assertEqual(get_record_dic[key],
                          result_collection[0].get(key),
                          "assertion failed for key {} ".format(key))
Exemplo n.º 6
0
    def update(self, model, entity_id):

        record = kate4.query.get(entity_id)  # kate4 is a mongo class
        if record is None:
            raise kate4ServiceError('kate4 {} not found'.format(entity_id),
                                    ErrorCodes.NOT_FOUND)

        for key in model:
            record.__setattr__(key, model[key])
        record.modifiedBy = self.auth_context.user_id
        record.modifiedDate = str(int(time.time()))
        record.save()
        result = record.wrap()
        clean_nonserializable_attributes(result)
        return result
Exemplo n.º 7
0
    def save(self, model):
        new_data = omartestpy4()
        for key in model:
            new_data.__setattr__(key, model[key])
        data = new_data
        data.tenantId = self.auth_context.tenant_id
        data.orgId = self.auth_context.org_id
        data.createdBy = self.auth_context.user_id
        data.createdDate = str(int(time.time()))
        data.modifiedBy = self.auth_context.user_id
        data.modifiedDate = str(int(time.time()))
        data.save()
        result = data.wrap()

        clean_nonserializable_attributes(result)
        return result
Exemplo n.º 8
0
    def find_by_id(self, project_id, iteration_id, entity_id):
        # filter with id not working,
        # unable to proceed with tenant filter
        data = Artifacts.query.filter(
            Artifacts.orgId == self.auth_context.org_id,
            Artifacts.projectId == project_id,
            Artifacts.iterationId == iteration_id,
            Artifacts.mongo_id == entity_id).first()
        if data is None:
            raise ArtifactsServiceError(
                'artifacts {} not found'.format(entity_id),
                ErrorCodes.NOT_FOUND)

        data = data.wrap()
        clean_nonserializable_attributes(data)
        return data
Exemplo n.º 9
0
 def get(self, authcontext, entity_id):
     """gets an hjqubeship item that omar has changed
     """
     try:
         LOG.debug("Get details by id %s ", entity_id)
         data = hjqubeshipService(authcontext['context'])\
             .find_by_id(entity_id)
         clean_nonserializable_attributes(data)
     except hjqubeshipServiceError as e:
         LOG.error(e)
         return ErrorModel(**{'error_code': str(e.errors.value),
                              'error_message': e.args[0]}), e.errors
     except ValueError as e:
         LOG.error(e)
         return ErrorModel(**{'error_code': '400',
                              'error_message': e.args[0]}), 400
     return hjqubeshipModel(**data), 200
Exemplo n.º 10
0
    def get(self, authcontext, project_id, iteration_id):
        """
        gets all artifacts items
        """
        LOG.debug("Serving  Get all request")
        list = ArtifactsService(authcontext['context']).get_all(project_id,
                                                                iteration_id)
        artifacts_list = []
        for data in list:
            clean_nonserializable_attributes(data)
            if 'url' in data:
                del data['url']
            artifacts_list_model = ArtifactListModel(**data)
            artifacts_list.append(artifacts_list_model)

        # normalize the name for 'id'
        return artifacts_list, 200
Exemplo n.º 11
0
 def get(self, authcontext, project_id, iteration_id, entity_id):
     """gets an artifacts item
     """
     try:
         LOG.debug("Get details by id %s %s %s", project_id, iteration_id,
                   entity_id)
         data = ArtifactsService(authcontext['context'])\
             .find_by_id(project_id, iteration_id, entity_id)
         clean_nonserializable_attributes(data)
     except ArtifactsServiceError as e:
         LOG.error(e)
         return ErrorModel(**{'error_code': str(e.errors.value),
                              'error_message': e.args[0]}), e.errors
     except ValueError as e:
         LOG.error(e)
         return ErrorModel(**{'error_code': '400',
                              'error_message': e.args[0]}), 400
     return ArtifactsModel(**data), 200
Exemplo n.º 12
0
    def save(self, model, project_id, iteration_id):
        new_data = Artifacts()
        for key in model:
            new_data.__setattr__(key, model[key])
        data = new_data
        data.tenantId = self.auth_context.tenant_id
        data.orgId = self.auth_context.org_id
        data.projectId = project_id
        data.iterationId = iteration_id
        data.createdBy = self.auth_context.user_id
        data.createdDate = str(int(time.time()))
        data.modifiedBy = self.auth_context.user_id
        data.modifiedDate = str(int(time.time()))
        data.save()
        result = data.wrap()

        clean_nonserializable_attributes(result)
        return result
Exemplo n.º 13
0
 def test_get_artifacts(self, *args, **kwargs):
     id_to_get = str(self.data.mongo_id)
     rv = self.test_client.get(ARTIFACT_URL.format(PROJECT_ID,
                                                   ITERATION_ID),
                               headers=self.headers)
     result_collection = json.loads(rv.data.decode('utf-8'))
     self.assertTrue(rv._status_code == 200,
                     "got status code " + str(rv.status_code))
     self.assertTrue(len(result_collection) == 1)
     self.assertTrue(result_collection[0].get('id') == id_to_get)
     get_record_dic = self.data.wrap()
     clean_nonserializable_attributes(get_record_dic)
     if 'url' in get_record_dic:
         del get_record_dic['url']
     self.assertFalse('url' in result_collection[0])
     for key in get_record_dic:
         self.assertEqual(get_record_dic[key],
                          result_collection[0].get(key),
                          "assertion failed for key {} ".format(key))
Exemplo n.º 14
0
    def update(self, model, project_id, iteration_id, entity_id):
        # Artifacts is a mongo class
        record = Artifacts.query.filter(
            Artifacts.orgId == self.auth_context.org_id,
            Artifacts.projectId == project_id,
            Artifacts.iterationId == iteration_id,
            Artifacts.mongo_id == entity_id).first()
        if record is None:
            raise ArtifactsServiceError(
                'artifacts {} not found'.format(entity_id),
                ErrorCodes.NOT_FOUND)

        for key in model:
            record.__setattr__(key, model[key])
        record.modifiedBy = self.auth_context.user_id
        record.modifiedDate = str(int(time.time()))
        record.save()
        result = record.wrap()
        clean_nonserializable_attributes(result)
        return result