Пример #1
0
def layout(project, format_type):
    # lt = str(pathname).strip("/").split("/")
    # project = lt[0]
    # action = lt[-1]
    # api_id = lt[1] if len(lt) == 3 else None
    # print(api_id)
    # if not (action == "export"):
    #     return

    json_data = read_project_file()
    prj = [p for p in json_data if p["Project"] == project][0]
    lt = []

    for t in prj["TestCase"]:
        t["Project"] = prj["Project"]
        t["Description"] = prj["Description"]
        lt.append(t)

    df = pd.DataFrame(lt)
    df.set_index(["Project"], inplace=True)
    print(df)
    if format_type == "csv":
        return export_csv(df, project)
    else:
        return export_excel(df, project)
Пример #2
0
def layout(pathname):
    lt = str(pathname).strip("/").split("/")
    project = lt[0]
    action = lt[-1]
    api_id = lt[1] if len(lt) == 3 else None

    projects_new = read_project_file()
    projects_delete = [x for x in projects_new if x["Project"] == project]

    print("{} action for project {}".format(action, project))
    if action == "delete":
        for pr in projects_delete:
            projects_new.remove(pr)
        if api_id:
            apis = [
                y for x in projects_delete for y in x["TestCase"]
                if y["ID"] == api_id
            ]
            for api in apis:
                projects_delete[0]["TestCase"].remove(api)

            projects_new.extend(projects_delete)
            write_project_file(projects_new)
            return dbc.Container(
                [html.H1("Deleted Test Case from {} ".format(project))])

        write_project_file(projects_new)

        print("deleted {} ".format(project))
        return dbc.Container([html.H1("Deleted project {} ".format(project))])
Пример #3
0
def get_test_cards(project):
    projects = read_project_file()
    test_cases = [y["TestCase"] for y in projects if y["Project"] == project]
    test_cases = test_cases[0] if test_cases else test_cases

    test_case_cards = [
        CreateTestCard(project, y["API"], y["ID"], y["Method"],
                       y["Status"]).get() for y in test_cases
    ]

    test_create_button = dbc.Button("+",
                                    id="Create_Test_Case_Btn_ID",
                                    style={
                                        "width": "20rem",
                                        "height": "8rem"
                                    })

    test_case_cards.append(test_create_button)

    i = 3
    cards = [
        dbc.Row([
            dbc.Col(y, width="auto") for y in
            test_case_cards[x * i:x * i + i if x * i +
                            i < len(test_case_cards) else len(test_case_cards)]
        ]) for x in range(i)
    ]
    return cards
Пример #4
0
def layout(pathname):
    lt = str(pathname).strip("/").split("/")
    project = lt[0]
    action = lt[-1]
    if not (action == "test"):
        return

    api_id = lt[1] if len(lt) == 3 else None

    projects_new = read_project_file()

    lt = []
    for p in projects_new:
        if p["Project"] == project:
            if api_id:
                for tc in p["TestCase"]:
                    if tc["ID"] == api_id:
                        lt.append(RunTestCase().run(tc))
            else:
                lt = [
                    html.H1("Testing project {} ".format(project), style={"text-align": "center", "color": "Blue"})
                ]
                for test_case in p["TestCase"]:
                    lt.append(RunTestCase().run(test_case))

    write_project_file(projects_new)
    return dbc.Container(
        lt
    )
Пример #5
0
def project_list():
    projects = read_project_file()
    list_of_projects = [
        dbc.Row([
            dbc.Col([CreateProjectCard(x["Project"], x["Description"]).get()],
                    width="auto")
        ]) for x in projects
    ]
    return html.Div(list_of_projects)
Пример #6
0
def layout(project):
    project = project.replace("%20", " ")
    projects = read_project_file()
    print("[x[Project] for x in projects] :", [x["Project"] for x in projects])
    is_exist = project in [x["Project"] for x in projects]
    if is_exist:
        return html.Div([
            html.H1("Project : {}".format(project),
                    style={"text-align": "center"}),
            dbc.Container(get_test_cards(project), className="my-1"),
            CreateTestCaseModal(project).get()
        ], )
    else:
        return dbc.Container([html.H1("Invalid Project : {}".format(project))])
Пример #7
0
def toggle_modal(n1, n2, is_open, project, description):
    print(n1, n2)
    if n1 or n2:
        if project and description:
            print(project, description)
            projects = read_project_file()
            p = {
                "Project": project,
                "Description": description,
                "TestCase": []
            }
            projects.append(p)
            write_project_file(projects)
        return not is_open
    return is_open
Пример #8
0
def toggle_modal(n1, n2, is_open, project, api, method, body):
    print(n1, n2)
    if n1 or n2:
        if api and method:
            print(api, method)
            projects = read_project_file()
            p = [x for x in projects if x["Project"] == project][0]
            api_id = str(datetime.now()).replace(" ",
                                                 "").replace(":", "").replace(
                                                     "-", "").replace(".", "")

            t = {
                "ID": "{}_{}".format(project, api_id),
                "API": api,
                "Body": json.dumps(body) if body else None,
                "Method": method,
                "Status": "Success"
            }
            p["TestCase"].append(t)
            write_project_file(projects)
        return not is_open
    return is_open