Exemple #1
0
def test_get_all(reqmock):
    run_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_tests/{run_id}",
        status_code=200,
        text='''[{
            "assignedto_id": 1,
            "case_id": 1,
            "custom_expected": "..",
            "custom_preconds": "..",
            "custom_steps_separated": [
                {
                    "content": "Step 1",
                    "expected": "Expected Result 1"
                },
                {
                    "content": "Step 2",
                    "expected": "Expected Result 2"
                }
            ],
            "estimate": "1m 5s",
            "estimate_forecast": null,
            "id": 100,
            "priority_id": 2,
            "run_id": 1,
            "status_id": 5,
            "title": "Verify line spacing on multi-page document",
            "type_id": 4
        }]''')

    res = t.get_all(run_id=run_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
Exemple #2
0
def test_get_all(reqmock):
    test_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_results/{test_id}",
                status_code=200,
                text='''[{
            "assignedto_id": 1,
            "comment": "This test failed: ..",
            "created_by": 1,
            "created_on": 1393851801,
            "custom_step_results": [{
                "..": "..."
            }],
            "defects": "TR-1",
            "elapsed": "5m",
            "id": 1,
            "status_id": 5,
            "test_id": 1,
            "version": "1.0RC1"
        }]''')

    res = r.get_all(test_id=test_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
    assert "assignedto_id" in res[0].keys()
    assert "comment" in res[0].keys()
    assert "created_by" in res[0].keys()
    assert "created_on" in res[0].keys()
    assert "custom_step_results" in res[0].keys()
    assert "defects" in res[0].keys()
    assert "elapsed" in res[0].keys()
    assert "id" in res[0].keys()
    assert "status_id" in res[0].keys()
    assert "test_id" in res[0].keys()
    assert "version" in res[0].keys()
Exemple #3
0
def test_get_all(reqmock):
    project_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_sections/{project_id}",
        status_code=200,
        text='''[
            {
                "depth": 0,
                "display_order": 1,
                "id": 1,
                "name": "Prerequisites",
                "parent_id": null,
                "suite_id": 1
            },
            {
                "depth": 0,
                "display_order": 2,
                "id": 2,
                "name": "Documentation & Help",
                "parent_id": null,
                "suite_id": 1
            },
            {
                "depth": 1,
                "display_order": 3,
                "id": 3,
                "name": "Licensing & Terms",
                "parent_id": 2,
                "suite_id": 1
            }
        ]''')

    res = s.get_all(project_id=project_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
Exemple #4
0
def test_get_all_from_test_case(reqmock):
    run_id = 1
    case_id = 1
    reqmock.get(
        f"{BASEURL}/index.php?/api/v2/get_results_for_case/{run_id}/{case_id}",
        status_code=200,
        text='''[{
            "assignedto_id": 1,
            "comment": "This test failed: ..",
            "created_by": 1,
            "created_on": 1393851801,
            "custom_step_results": [{
                "..": "..."
            }],
            "defects": "TR-1",
            "elapsed": "5m",
            "id": 1,
            "status_id": 5,
            "test_id": 1,
            "version": "1.0RC1"
        }]''')

    res = r.get_all_from_test_case(run_id=run_id, case_id=case_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
Exemple #5
0
def test_get_from_case(reqmock):
    case_id = 100
    reqmock.get(
        f"{BASEURL}/index.php?/api/v2/get_attachments_for_case/{case_id}",
        status_code=200,
        text="""[
            {
                "id": 444,
                "name": "What-Testers-Should-Be-Automating.jpg",
                "filename": "444.what_testers_should_be_automating.jpg",
                "size": 166994,
                "created_on": 1554737184,
                "project_id": 14,
                "case_id": 3414,
                "test_change_id": 17899,
                "user_id": 10
            }
        ]""")

    res = a.get_from_case(case_id)
    assert res is not None
    assert "id" in res[0].keys()
    assert "name" in res[0].keys()
    assert "filename" in res[0].keys()
    assert "size" in res[0].keys()
    assert "created_on" in res[0].keys()
    assert "project_id" in res[0].keys()
    assert "case_id" in res[0].keys()
    assert "test_change_id" in res[0].keys()
    assert "user_id" in res[0].keys()
Exemple #6
0
def test_get(reqmock):
    milestone_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_milestone/{milestone_id}",
        status_code=200,
        text='''{
            "completed_on": 1389968184,
            "description": "...",
            "due_on": 1391968184,
            "id": 1,
            "is_completed": true,
            "name": "Release 1.5",
            "project_id": 1,
            "url": "http:///testrail/index.php?/milestones/view/1"
        }''')

    res = m.get(milestone_id=milestone_id)
    assert res is not None
    assert type(res) == dict
    assert "completed_on" in res.keys()
    assert "description" in res.keys()
    assert "due_on" in res.keys()
    assert "id" in res.keys()
    assert "is_completed" in res.keys()
    assert "name" in res.keys()
    assert "project_id" in res.keys()
    assert "url" in res.keys()
Exemple #7
0
def test_get(reqmock):
    project_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_templates/{project_id}",
                status_code=200,
                text='''[
            {
                "id": 1,
                "is_default": true,
                "name": "Test Case (Text)"
            },
            {
                "id": 2,
                "is_default": false,
                "name": "Test Case (Steps)"
            },
            {
                "id": 3,
                "is_default": false,
                "name": "Exploratory Session"
            }
        ]''')

    res = t.get(project_id=project_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
    assert "id" in res[0].keys()
    assert "is_default" in res[0].keys()
    assert "name" in res[0].keys()
Exemple #8
0
def test_get_all(reqmock):
    project_id = 10
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_cases/{project_id}",
        status_code=200,
        text='''[{
            "created_by": 5,
            "created_on": 1392300984,
            "custom_expected": "..",
            "custom_preconds": "..",
            "custom_steps": "..",
            "custom_steps_separated": [
                {
                    "content": "Step 1",
                    "expected": "Expected Result 1"
                },
                {
                    "content": "Step 2",
                    "expected": "Expected Result 2"
                }
            ],
            "estimate": "1m 5s",
            "estimate_forecast": null,
            "id": 1,
            "milestone_id": 7,
            "priority_id": 2,
            "refs": "RF-1, RF-2",
            "section_id": 1,
            "suite_id": 1,
            "title": "Change document attributes (author, title, organization)",
            "type_id": 4,
            "updated_by": 1,
            "updated_on": 1393586511
        }]''')
    res = case.get_all(project_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
    assert "created_by" in res[0].keys()
    assert "created_on" in res[0].keys()
    assert "custom_expected" in res[0].keys()
    assert "custom_preconds" in res[0].keys()
    assert "custom_steps" in res[0].keys()
    assert "custom_steps_separated" in res[0].keys()
    assert "estimate" in res[0].keys()
    assert "estimate_forecast" in res[0].keys()
    assert "id" in res[0].keys()
    assert "milestone_id" in res[0].keys()
    assert "priority_id" in res[0].keys()
    assert "refs" in res[0].keys()
    assert "section_id" in res[0].keys()
    assert "suite_id" in res[0].keys()
    assert "title" in res[0].keys()
    assert "type_id" in res[0].keys()
    assert "updated_by" in res[0].keys()
    assert "updated_on" in res[0].keys()
Exemple #9
0
def test_get(reqmock):
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_statuses",
        status_code=200,
        text='''[
            {
                "color_bright": 12709313,
                "color_dark": 6667107,
                "color_medium": 9820525,
                "id": 1,
                "is_final": true,
                "is_system": true,
                "is_untested": false,
                "label": "Passed",
                "name": "passed"
            },
            {
                "color_bright": 16631751,
                "color_dark": 14250867,
                "color_medium": 15829135,
                "id": 5,
                "is_final": true,
                "is_system": true,
                "is_untested": false,
                "label": "Failed",
                "name": "failed"
            },
            {
                "color_bright": 13684944,
                "color_dark": 0,
                "color_medium": 10526880,
                "id": 6,
                "is_final": false,
                "is_system": false,
                "is_untested": false,
                "label": "Custom",
                "name": "custom_status1"
            }
        ]''')

    res = s.get()
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
    assert "color_bright" in res[0].keys()
    assert "color_dark" in res[0].keys()
    assert "color_medium" in res[0].keys()
    assert "id" in res[0].keys()
    assert "is_final" in res[0].keys()
    assert "is_system" in res[0].keys()
    assert "is_untested" in res[0].keys()
    assert "label" in res[0].keys()
    assert "name" in res[0].keys()
Exemple #10
0
def test_get(reqmock):
    attachment_id = 444
    file_path = '../data/new_attachment.txt'
    check_file(file_path)
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_attachment/{attachment_id}",
                status_code=200,
                text='''Test''')

    res = a.get(attachment_id, file_path)
    assert res is not None
    assert type(res) == str
    assert res == "Test"
    os.remove(file_path)
Exemple #11
0
def test_get_all(reqmock):
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_users",
        status_code=200,
        text='''[{
            "email": "*****@*****.**",
            "id": 1,
            "is_active": true,
            "name": "Alexis Gonzalez"
        }]''')

    res = u.get_all()
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
Exemple #12
0
def test_get(reqmock):
    project_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_reports/{project_id}",
                status_code=200,
                text='''[{
            "id": 1,
            "name": "Activity Summary (Cases) %date%",
            "description": null,
            "notify_user": true,
            "notify_link": false,
            "notify_link_recipients": null,
            "notify_attachment": false,
            "notify_attachment_recipients": "[email protected],[email protected]",
            "notify_attachment_html_format": false,
            "notify_attachment_pdf_format": false,
            "cases_groupby": "day",
            "changes_daterange": "5",
            "changes_daterange_from": null,
            "changes_daterange_to": null,
            "suites_include": "1",
            "suites_ids": null,
            "sections_include": "1",
            "sections_ids": null,
            "cases_columns": {
                "cases:id": 75,
                "cases:title": 0,
                "cases:created_by": 125,
                "cases:updated_by": 125
            },
            "cases_filters": null,
            "cases_limit": 1000,
            "content_hide_links": false,
            "cases_include_new": true,
            "cases_include_updated": true
        }]''')

    res = r.get(project_id=project_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
    assert "id" in res[0].keys()
    assert "name" in res[0].keys()
    assert "description" in res[0].keys()
    assert "notify_user" in res[0].keys()
    assert "notify_link" in res[0].keys()
    assert "notify_link_recipients" in res[0].keys()
    assert "notify_attachment" in res[0].keys()
    assert "notify_attachment_html_format" in res[0].keys()
    assert "notify_attachment_pdf_format" in res[0].keys()
Exemple #13
0
def test_get_by_email(reqmock):
    email = "*****@*****.**"
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_user_by_email&email={email}",
        status_code=200,
        text='''{
            "email": "*****@*****.**",
            "id": 1,
            "is_active": true,
            "name": "Alexis Gonzalez"
        }''')

    res = u.get_by_email(email_addr=email)
    assert res is not None
    assert type(res) == dict
    assert "email" in res.keys()
    assert res["email"] == email
Exemple #14
0
def test_get_all(reqmock):
    project_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_suites/{project_id}",
                status_code=200,
                text='''[{
            "description": "This is a test suite",
            "id": 1,
            "name": "Setup & Installation",
            "project_id": 1,
            "url": "http:///testrail/index.php?/suites/view/1"
        }]''')

    res = s.get_all(project_id=project_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
Exemple #15
0
def test_run(reqmock):
    report_template_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/run_report/{report_template_id}",
                status_code=200,
                text='''{
            "report_url": "https://docs.testrail.com/index.php?/reports/view/383",
            "report_html": "https://docs.testrail.com/index.php?/reports/get_html/383",
            "report_pdf": "https://docs.testrail.com/index.php?/reports/get_pdf/383"
        }''')

    res = r.run(report_template_id=report_template_id)
    assert res is not None
    assert type(res) == dict
    assert "report_url" in res.keys()
    assert "report_html" in res.keys()
    assert "report_pdf" in res.keys()
def test_get_result_fields(reqmock):
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_result_fields",
                status_code=200,
                text='''[
            {
                "configs": [
                    {
                        "context": {
                            "is_global": true,
                            "project_ids": null
                        },
                        "id": "..",
                        "options": {
                            "format": "markdown",
                            "has_actual": false,
                            "has_expected": true,
                            "is_required": false
                        }
                    }
                ],
                "description": null,
                "display_order": 1,
                "id": 5,
                "label": "Steps",
                "name": "step_results",
                "system_name": "custom_step_results",
                "type_id": 11
            }
        ]''')

    res = rf.get()
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
    assert "configs" in res[0].keys()
    assert type(res[0]["configs"]) == list
    assert type(res[0]["configs"][0]) == dict
    assert "context" in res[0]["configs"][0]
    assert "id" in res[0]["configs"][0]
    assert "options" in res[0]["configs"][0]
    assert "description" in res[0].keys()
    assert "display_order" in res[0].keys()
    assert "id" in res[0].keys()
    assert "label" in res[0].keys()
    assert "name" in res[0].keys()
    assert "system_name" in res[0].keys()
    assert "type_id" in res[0].keys()
Exemple #17
0
def test_get(reqmock):
    user_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_user/{user_id}",
        status_code=200,
        text='''{
            "email": "*****@*****.**",
            "id": 1,
            "is_active": true,
            "name": "Alexis Gonzalez"
        }''')

    res = u.get(user_id=user_id)
    assert res is not None
    assert type(res) == dict
    assert "email" in res.keys()
    assert "id" in res.keys()
    assert "is_active" in res.keys()
    assert "name" in res.keys()
Exemple #18
0
def test_get_all(reqmock):
    project_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_milestones/{project_id}",
        status_code=200,
        text='''[{
            "completed_on": 1389968184,
            "description": "...",
            "due_on": 1391968184,
            "id": 1,
            "is_completed": true,
            "name": "Release 1.5",
            "project_id": 1,
            "url": "http:///testrail/index.php?/milestones/view/1"
        }]''')
    res = m.get_all(project_id=project_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
Exemple #19
0
def test_get_all(reqmock):
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_case_fields",
        status_code=200,
        text='''[
            {
                "configs": [
                    {
                        "context": {
                            "is_global": true,
                            "project_ids": null
                        },
                        "id": "..",
                        "options": {
                            "default_value": "",
                            "format": "markdown",
                            "is_required": false,
                            "rows": "5"
                        }
                    }
                ],
                "description": "The preconditions of this test case. ..",
                "display_order": 1,
                "id": 1,
                "label": "Preconditions",
                "name": "preconds",
                "system_name": "custom_preconds",
                "type_id": 3
            }
        ]''')

    res = cf.get_all()
    assert res is not None
    assert "configs" in res[0].keys()
    assert "context" in res[0]["configs"][0].keys()
    assert "options" in res[0]["configs"][0].keys()
    assert "id" in res[0]["configs"][0].keys()
    assert "description" in res[0].keys()
    assert "display_order" in res[0].keys()
    assert "id" in res[0].keys()
    assert "label" in res[0].keys()
    assert "name" in res[0].keys()
    assert "system_name" in res[0].keys()
    assert "type_id" in res[0].keys()
Exemple #20
0
def test_get_all(reqmock):
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_priorities",
                status_code=200,
                text='''[{
                "id": 1,
                "is_default": false,
                "name": "1 - Don't Test",
                "priority": 1,
                "short_name": "1 - Don't"
            }]''')
    res = p.get_all()
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
    assert "id" in res[0].keys()
    assert "is_default" in res[0].keys()
    assert "name" in res[0].keys()
    assert "priority" in res[0].keys()
    assert "short_name" in res[0].keys()
Exemple #21
0
def test_get(reqmock):
    suite_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_suite/{suite_id}",
                status_code=200,
                text='''{
            "description": "This is a test suite",
            "id": 1,
            "name": "Setup & Installation",
            "project_id": 1,
            "url": "http:///testrail/index.php?/suites/view/1"
        }''')

    res = s.get(suite_id=suite_id)
    assert res is not None
    assert type(res) == dict
    assert "description" in res.keys()
    assert "id" in res.keys()
    assert "name" in res.keys()
    assert "project_id" in res.keys()
    assert "url" in res.keys()
Exemple #22
0
def test_get_all(reqmock):
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_case_types",
                status_code=200,
                text='''[{
                "id": 1,
                "is_default": false,
                "name": "Automated"
            },
            {
                "id": 2,
                "is_default": false,
                "name": "Functionality"
            }]''')

    res = ct.get_all()
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
    assert res[0]["id"] == 1
    assert res[0]["is_default"] is False
    assert res[0]["name"] == "Automated"
Exemple #23
0
def test_get(reqmock):
    section_id = 1
    reqmock.get(f"{BASEURL}/index.php?/api/v2/get_section/{section_id}",
        status_code=200,
        text='''{
            "depth": 0,
            "description": null,
            "display_order": 1,
            "id": 1,
            "name": "Prerequisites",
            "parent_id": null,
            "suite_id": 1
        }''')

    res = s.get(section_id=section_id)
    assert res is not None
    assert type(res) == dict
    assert "depth" in res.keys()
    assert "description" in res.keys()
    assert "display_order" in res.keys()
    assert "id" in res.keys()
    assert "name" in res.keys()
    assert "parent_id" in res.keys()
    assert "suite_id" in res.keys()
def test_get_all(reqmock):
    project_id = 100
    reqmock.get(
        f"{BASEURL}/index.php?/api/v2/get_configs/{project_id}",
        status_code=200,
        text='''[
            {
                "configs": [
                    {
                        "group_id": 1,
                        "id": 1,
                        "name": "Chrome"
                    },
                    {
                        "group_id": 1,
                        "id": 2,
                        "name": "Firefox"
                    },
                    {
                        "group_id": 1,
                        "id": 3,
                        "name": "Internet Explorer"
                    }
                ],
                "id": 1,
                "name": "Browsers",
                "project_id": 1
            },
            {
                "configs": [
                    {
                        "group_id": 2,
                        "id": 6,
                        "name": "Ubuntu 12"
                    },
                    {
                        "group_id": 2,
                        "id": 4,
                        "name": "Windows 7"
                    },
                    {
                        "group_id": 2,
                        "id": 5,
                        "name": "Windows 8"
                    }
                ],
                "id": 2,
                "name": "Operating Systems",
                "project_id": 1
            }
        ]''',
    )

    res = conf.get_all(project_id=project_id)
    assert res is not None
    assert type(res) == list
    assert type(res[0]) == dict
    assert "configs" in res[0].keys()
    assert type(res[0]["configs"]) == list
    assert type(res[0]["configs"][0]) == dict
    assert "group_id" in res[0]["configs"][0]
    assert "id" in res[0]["configs"][0]
    assert "name" in res[0]["configs"][0]