Пример #1
0
def gen_req():
    req = nCoV_diagnosis_engine_pb2.DPRequest()
    req.common_req.CopyFrom(
        CommonPbHelper.hard_code_common_req(version='0.1.0',
                                            request_id='1',
                                            user_id='2',
                                            session_id='3',
                                            trace_id='4'))
    req.strategy = 'v3_en'
    return req
Пример #2
0
import pytest
import yaml

from server.protobufs.gen.pb_python import nCoV_diagnosis_engine_pb2
from server.config.config import load_config
from server.engine.nCoV_test_engine import nCoVTestEngine, check_advance_reason
from server.utils.common_help import Session

config = load_config()
engine = nCoVTestEngine(config)

from google.protobuf.json_format import ParseDict, MessageToDict
temp_req = nCoV_diagnosis_engine_pb2.DPRequest()


def _real_test(qs, answer_index):
    his = []
    for q in qs:
        question = nCoV_diagnosis_engine_pb2.DetailedQuestions()
        ParseDict(q, question, ignore_unknown_fields=True)
        his.append(question)
    with Session(temp_req, None) as context:
        ret_code, _, result = engine.predict(context,
                                             his_questions=his,
                                             strategy='beijing')
        assert ret_code == 0
        assert result['reply_type'] == nCoV_diagnosis_engine_pb2.NO_NEED
        assert result['answer_index'] == answer_index

        context.mark_succ('Quiz', 1 if ret_code == 0 else 0, ret_code)