def test():
    django.setup()
    feature_id = 1
    feature = Feature.objects.filter(id=feature_id).first()
    workspace = WorkSpace.objects.get(pk=feature.workspace)
    workspace_path = workspace.getFolderPath()
    dict = Step.getStepByFolder(workspace_path)
    file_path = FeatureFileGenerator.get_workspace_entrance(workspace)
    feature = lettuce.Feature.from_file(file_path)
    feature_dto = FeatureDto(feature.name, feature.description)
    scenarios = []
    for sce in feature.scenarios:
        s_dto = ScenarioDto('id_missing', sce.name)
        for s_item in sce.steps:
            co_func, patten, result = match_definision(s_item, dict)
            action_type, varlist_tuple, variables = extract_func_info(co_func, s_item, result)
            step_dto = StepDto()
            func_code = co_func.func_code
            step_dto.fill(func_code.co_filename, func_code.co_firstlineno, func_code.co_argcount,
                          varlist_tuple, func_code.co_name, co_func.func_name, action_type, variables, patten,
                          'id_no_use')
            s_dto.steps.append(step_dto)
        scenarios.append(s_dto)
    feature_dto.fill_scenarios(scenarios)
    return json.dumps((feature_dto), cls=DataEncoder)
Exemple #2
0
 def searchStep(key_word, type):
     feature_locations = FeatureLocation.objects.filter(type=type)
     result = {}
     for fl in feature_locations:
         dict = Step.getStepByFolder('../' + fl.location)
         keys = dict.keys()
         temp = {}
         for key in keys:
             # pdb.set_trace()
             step_dto = StepDto()
             step_dto.co_filename = dict[key].func_code.co_filename
             step_dto.co_firstlineno = dict[key].func_code.co_firstlineno
             step_dto.co_argcount = dict[key].func_code.co_argcount
             step_dto.co_varnames = dict[key].func_code.co_varnames
             step_dto.co_name = dict[key].func_code.co_name
             step_dto.step_name = key
             temp[key] = step_dto
         result = result.copy()
         result.update(temp)
     return result