コード例 #1
0
def test_application_model_can_create_application():
    """Test application model can create application."""
    form = FormProcessMapper(
        id=1,
        form_id=12324,
        form_name="One Step Approval",
        form_revision_number=1,
        process_key=121312,
        process_name="test",
        status="Pending",
        comments="test",
        tenant_id=12,
    )
    assert form.id == 1
    application1 = Application(
        application_name="Test Form Application",
        application_status="Approved",
        form_url="https://testsample.com/api/form/123/submission/2313",
        process_instance_id="213123",
        revision_no=1,
        form_process_mapper_id=1,
    )

    assert application1.application_name == "Test Form Application"
    assert application1.application_status == "Approved"
    assert (application1.form_url ==
            "https://testsample.com/api/form/123/submission/2313")
コード例 #2
0
 def get_all_mappers(page_number: int, limit: int):
     """Get all form process mappers."""
     if page_number:
         page_number = int(page_number)
     if limit:
         limit = int(limit)
     mappers = FormProcessMapper.find_all_active(page_number=page_number,
                                                 limit=limit)
     mapper_schema = FormProcessMapperSchema()
     return mapper_schema.dump(mappers, many=True)
コード例 #3
0
def test_formprocessmapper_creation():
    """Test FormProcessMapper can create"""
    form = FormProcessMapper(
        id=1,
        form_id=12324,
        form_name="One Step Approval",
        form_revision_number=1,
        process_key=121312,
        process_name="test",
        status="Pending",
        comments="test",
        tenant_id=12,
    )
    assert form.id == 1
    assert form.form_id == 12324
コード例 #4
0
 def mark_inactive(form_process_mapper_id):
     """Mark form process mapper as inactive."""
     application = FormProcessMapper.find_form_by_id_active_status(
         form_process_mapper_id=form_process_mapper_id)
     if application:
         application.mark_inactive()
     else:
         raise BusinessException(
             {
                 "type":
                 "Invalid response data",
                 "message":
                 f"Unable to set FormProcessMapperId - {form_process_mapper_id} inactive",
             },
             HTTPStatus.BAD_REQUEST,
         )
コード例 #5
0
    def get_mapper_by_formid(form_id):
        """Get form process mapper."""
        mapper = FormProcessMapper.find_form_by_form_id(form_id=form_id)
        if mapper:
            mapper_schema = FormProcessMapperSchema()
            return mapper_schema.dump(mapper)

        raise BusinessException(
            {
                "type":
                "No Response",
                "message":
                f"FormProcessMapper with FormID - {form_id} not stored in DB",
            },
            HTTPStatus.NO_CONTENT,
        )
コード例 #6
0
    def get_mapper(form_process_mapper_id):
        """Get form process mapper."""
        mapper = FormProcessMapper.find_form_by_id_active_status(
            form_process_mapper_id=form_process_mapper_id)
        if mapper:
            mapper_schema = FormProcessMapperSchema()
            return mapper_schema.dump(mapper)

        raise BusinessException(
            {
                "type":
                "Invalid response data",
                "message":
                f"Invalid form process mapper id - {form_process_mapper_id}",
            },
            HTTPStatus.BAD_REQUEST,
        )
コード例 #7
0
    def update_mapper(form_process_mapper_id, data):
        """Update form process mapper."""
        mapper = FormProcessMapper.find_form_by_id(
            form_process_mapper_id=form_process_mapper_id)
        if not ((data.get("process_key")) and (data.get("process_name"))):
            data["process_key"] = None
            data["process_name"] = None

        if not (data.get("comments")):
            data["comments"] = None

        if mapper:
            mapper.update(data)
            return mapper

        raise BusinessException(
            {
                "type":
                "Invalid response data",
                "message":
                f"Unable to updated FormProcessMapperId - {form_process_mapper_id}",
            },
            HTTPStatus.BAD_REQUEST,
        )
コード例 #8
0
 def create_mapper(data):
     """Create new mapper between form and process."""
     return FormProcessMapper.create_from_dict(data)
コード例 #9
0
 def get_mapper_count():
     """Get form process mapper count."""
     return FormProcessMapper.find_all_count()