示例#1
0
def test_delete_group(reqmock):
    config_group_id = 100
    reqmock.post(
        f"{BASEURL}/index.php?/api/v2/delete_config_group/{config_group_id}",
        text='',
        status_code=200)
    conf.delete_group(config_group_id=config_group_id)
示例#2
0
def test_add_child(reqmock):
    project_id = 1
    parent_id = 10
    reqmock.post(f"{BASEURL}/index.php?/api/v2/add_section/{project_id}",
        status_code=200,
        text='''{
            "depth": 0,
            "description": "This is the description",
            "display_order": 1,
            "id": 1,
            "name": "This is a new CHILD section", 
            "parent_id": 10,
            "suite_id": 5
        }''')

    data = {
        "suite_id": 5,
        "name": "This is a new CHILD section",
        "description": "This is the description",
        "parent_id": parent_id
    }

    res = s.add_child(project_id=project_id, parent_id=parent_id, data=data)
    assert res is not None
    assert type(res) == dict
示例#3
0
def test_delete(reqmock):
    section_id = 1
    reqmock.post(f"{BASEURL}/index.php?/api/v2/delete_section/{section_id}",
        status_code=200,
        text="")

    s.delete(section_id=section_id)
示例#4
0
def test_delete(reqmock):
    milestone_id = 1
    reqmock.post(f"{BASEURL}/index.php?/api/v2/delete_milestone/{milestone_id}",
        status_code=200,
        text='')
    res = m.delete(milestone_id=milestone_id)
    assert res is not None
示例#5
0
def test_delete(reqmock):
    attachment_id = 444
    reqmock.post(
        f"{BASEURL}/index.php?/api/v2/delete_attachment/{attachment_id}",
        status_code=200,
        text="""{}""")
    res = a.delete(attachment_id)
    assert res is not None
    assert type(res) == dict
示例#6
0
def test_add_group(reqmock):
    project_id = 100
    name = "Browsers"
    reqmock.post(f"{BASEURL}/index.php?/api/v2/add_config_group/{project_id}",
                 status_code=200,
                 text='''{
            "name": "Browsers"
        }''')
    res = conf.add_group(project_id=project_id, name=name)
    assert res is not None
    assert "name" in res.keys()
    assert res["name"] == name
示例#7
0
def test_add(reqmock):
    config_group_id = 100
    name = "Chrome"
    reqmock.post(f"{BASEURL}/index.php?/api/v2/add_config/{config_group_id}",
                 status_code=200,
                 text='''{
            "name": "Chrome"
        }''')
    res = conf.add(config_group_id=config_group_id, name=name)
    assert res is not None
    assert "name" in res.keys()
    assert res["name"] == name
示例#8
0
def test_update_group(reqmock):
    config_group_id = 100
    name = "Browsers"
    reqmock.post(
        f"{BASEURL}/index.php?/api/v2/update_config_group/{config_group_id}",
        status_code=200,
        text='''{
            "name": "Browsers"
        }''')
    res = conf.update_group(config_group_id=config_group_id, name=name)
    assert res is not None
    assert "name" in res.keys()
    assert res["name"] == name
示例#9
0
def test_add_to_run(reqmock):
    file_path = "attachment.txt"
    run_id = 100
    reqmock.post(f"{BASEURL}/index.php?/api/v2/add_attachment_to_run/{run_id}",
                 status_code=200,
                 text="""{
            "attachment_id": 443
        }""")

    res = a.add_to_run(run_id, file_path)
    assert res is not None
    assert type(res) == dict
    assert "attachment_id" in res.keys()
    assert res["attachment_id"] == 443
示例#10
0
def test_update(reqmock):
    suite_id = 1
    reqmock.post(f"{BASEURL}/index.php?/api/v2/update_suite/{suite_id}",
                 status_code=200,
                 text='''{
            "description": "This is a better description for test suite",
            "id": 1,
            "name": "Setup & Installation",
            "project_id": 1,
            "url": "http:///testrail/index.php?/suites/view/1"
        }''')

    data = {"description": "This is a better description for test suite"}
    res = s.update(suite_id=suite_id, data=data)
    assert res is not None
    assert type(res) == dict
示例#11
0
def test_update(reqmock):
    milestone_id = 1
    reqmock.post(f"{BASEURL}/index.php?/api/v2/update_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"
            }''')

    data = {"name": "Release 1.5", "description": "...", "due_on": 1391968184}
    res = m.update(milestone_id=milestone_id, data=data)
    assert res is not None
示例#12
0
def test_add_results(reqmock):

    run_id = 1
    reqmock.post(f"{BASEURL}/index.php?/api/v2/add_results/{run_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"
        }]''')

    data = {
        "results": [{
            "test_id": 101,
            "status_id": 5,
            "comment": "This test failed",
            "defects": "TR-7"
        }, {
            "test_id": 102,
            "status_id": 1,
            "comment": "This test passed",
            "elapsed": "5m",
            "version": "1.0 RC1"
        }, {
            "test_id": 101,
            "assignedto_id": 5,
            "comment": "Assigned this test to Joe"
        }]
    }

    res = r.add_results(run_id=run_id, data=data)
    assert res is not None
示例#13
0
def test_update(reqmock):
    section_id = 1
    reqmock.post(f"{BASEURL}/index.php?/api/v2/update_section/{section_id}",
        status_code=200,
        text='''{
            "depth": 0,
            "description": null,
            "display_order": 1,
            "id": 1,
            "name": "A better section name",
            "parent_id": null,
            "suite_id": 1
        }''')

    data = {
        "name": "A better section name"
    }

    res = s.update(section_id=section_id, data=data)
    assert res is not None
    assert type(res) == dict
示例#14
0
def test_add_to_test_case(reqmock):
    run_id = 1
    case_id = 1
    reqmock.post(
        f"{BASEURL}/index.php?/api/v2/add_result_for_case/{run_id}/{case_id}",
        status_code=200,
        text='''{
            "assignedto_id": 6,
            "comment": "Test comment",
            "created_by": 1,
            "created_on": 1393851801,
            "custom_step_results": [{
                "..": "..."
            }],
            "defects": "TR-1",
            "elapsed": "1m",
            "id": 1,
            "status_id": 5,
            "test_id": 1,
            "version": "1.0RC1"
        }''')

    data = {
        "status_id": 5,
        "comment": "Test comment",
        "version": "1.0RC1",
        "elapsed": "1m",
        "defects": "TR-1",
        "assignedto_id": 6
    }

    res = r.add_to_test_case(run_id=run_id, case_id=case_id, data=data)
    assert res is not None
    assert type(res) == dict
    assert res["status_id"] == 5
    assert res["comment"] == "Test comment"
    assert res["version"] == "1.0RC1"
    assert res["elapsed"] == "1m"
    assert res["defects"] == "TR-1"
    assert res["assignedto_id"] == 6
示例#15
0
def test_update(reqmock):
    case_id = 100
    data = {}
    reqmock.post(f"{BASEURL}/index.php?/api/v2/update_case/{case_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.update(case_id, data)
    assert res is not None
    assert type(res) == dict
示例#16
0
def test_add(reqmock):

    reqmock.post(f"{BASEURL}/index.php?/api/v2/add_case_field",
        status_code=200,
        text="""{
            "id": 33,
            "name": "My New Field",
            "system_name": "my_new_field",
            "entity_id": 1,
            "label": "My Multiselect",
            "description": "my custom Multiselect description",
            "type_id": 12,
            "location_id": 2,
            "display_order": 7,
            "configs": [{\"context\":{\"is_global\":true,\"project_ids\":\"\"},\"options\":{\"is_required\":false,\"items\":\"1, One\\n2, Two\"},\"id\":\"9f105ba2-1ed0-45e0-b459-18d890bad86e\"}],
            "is_multi": 1,
            "is_active": 1,
            "status_id": 1,
            "is_system": 0,
            "include_all": 1,
            "template_ids": []
        }""")

    data = {
        "type": "12",
        "name": "my_multiselect",
        "label": "My Multiselect",
        "include_all": "true",
        "configs": [{
                "context": {
                    "is_global": "true",
                    "project_ids": ""
                },
                "options": {
                    "is_required": "false",
                    "items": "1, One\n2, Two"
                },
                "id": "9f105ba2-1ed0-45e0-b459-18d890bad86e"
        }]
    }

    res = cf.add(data)
    assert res is not None
    assert "description" in res.keys()
    assert "display_order" in res.keys()
    assert "id" in res.keys()
    assert "label" in res.keys()
    assert "name" in res.keys()
    assert "system_name" in res.keys()
    assert "type_id" in res.keys()
    assert "entity_id" in res.keys()
    assert "location_id" in res.keys()
    assert "is_multi" in res.keys()
    assert "is_active" in res.keys()
    assert "status_id" in res.keys()
    assert "is_system" in res.keys()
    assert "include_all" in res.keys()
    assert "template_ids" in res.keys()
    assert res["id"] == 33
    assert res["name"] == "My New Field"
    assert res["system_name"] == "my_new_field"
示例#17
0
def test_delete(reqmock):
    case_id = 100
    reqmock.post(f"{BASEURL}/index.php?/api/v2/delete_case/{case_id}", status_code=200, text='')
    case.delete(case_id)
示例#18
0
def test_delete_test_suite(reqmock):
    suite_id = 1
    reqmock.post(f"{BASEURL}/index.php?/api/v2/delete_suite/{suite_id}",
                 status_code=200,
                 text='')
    s.delete_test_suite(suite_id=suite_id)