コード例 #1
0
 def assert_org_update_fails_invalid_org(org, new_name):
     with pytest.raises(StatusCodeException) as e:
         org.update(name=new_name)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=500,
         method="POST",
         url=utils.get_url("organization"),
         data={"error": "Failed to update organization"},
     )
コード例 #2
0
 def assert_get_metadata_fails(client):
     with pytest.raises(StatusCodeException) as e:
         client.metadata.get_metadata()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="GET",
         url=utils.get_url("metadata"),
         data={"msg": "Missing Authorization Header"},
     )
コード例 #3
0
 def assert_password_incorrect(username, password, org):
     with pytest.raises(StatusCodeException) as e:
         utils.get_client_org(username, password, org)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="POST",
         url=utils.get_url("auth/login"),
         data={"error": "Invalid login"},
     )
コード例 #4
0
 def assert_org_delete_invalid(org):
     with pytest.raises(StatusCodeException) as e:
         org.delete()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=503,
         method="DELETE",
         url=utils.get_url("organization"),
         data={"error": "Organization not found"},
     )
コード例 #5
0
 def assert_login_invalid(client, username, password):
     with pytest.raises(StatusCodeException) as e:
         client.login(username, password)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="POST",
         url=utils.get_url("auth/login"),
         data={"error": "Invalid login"},
     )
コード例 #6
0
 def assert_org_list_projects_fails(org):
     with pytest.raises(StatusCodeException) as e:
         org.list_projects()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="GET",
         url=utils.get_url(f"organization/{org.tag}"),
         data={"msg": "Missing Authorization Header"},
     )
コード例 #7
0
 def assert_org_list_projects_invalid(org):
     with pytest.raises(StatusCodeException) as e:
         org.list_projects()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=503,
         method="GET",
         url=utils.get_url(f"organization/{org.tag}"),
         data={"error": "Failed to retrieve organization info"},
     )
コード例 #8
0
 def assert_change_password_fails(client, old_password, new_password):
     with pytest.raises(StatusCodeException) as e:
         client.users.change_password(old_password, new_password)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="POST",
         url=utils.get_url("changepwd"),
         data={"msg": "Missing Authorization Header"},
     )
コード例 #9
0
 def assert_list_orgs_fails(client):
     with pytest.raises(StatusCodeException) as e:
         client.organizations.list_organizations()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="GET",
         url=utils.get_url("organization/all"),
         data={"msg": "Missing Authorization Header"},
     )
コード例 #10
0
 def assert_get_org_by_tag_fails(client, tag):
     with pytest.raises(StatusCodeException) as e:
         client.organizations.get_organization_by_tag(tag)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="GET",
         url=utils.get_url(f"organization/{tag}"),
         data={"msg": "Missing Authorization Header"},
     )
コード例 #11
0
 def assert_org_update_fails_missing_auth(org, new_name):
     with pytest.raises(StatusCodeException) as e:
         org.update(name=new_name)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="POST",
         url=utils.get_url("organization"),
         data={"msg": "Missing Authorization Header"},
     )
コード例 #12
0
 def assert_refresh_fails(client):
     with pytest.raises(StatusCodeException) as e:
         client.refresh()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="POST",
         url=utils.get_url("auth/refresh"),
         data={"msg": "Missing Authorization Header"},
     )
コード例 #13
0
 def assert_org_update_fails_exists(org, new_name):
     with pytest.raises(StatusCodeException) as e:
         org.update(name=new_name)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=400,
         method="POST",
         url=utils.get_url("organization"),
         data={"error": f"Organization {new_name} already exists"},
     )
コード例 #14
0
 def assert_create_org_fails(client, name):
     with pytest.raises(StatusCodeException) as e:
         client.organizations.create_organization(name)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="PUT",
         url=utils.get_url("organization"),
         data={"msg": "Missing Authorization Header"},
     )
コード例 #15
0
 def assert_create_org_invalid(client, name):
     with pytest.raises(StatusCodeException) as e:
         client.organizations.create_organization(name)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=400,
         method="PUT",
         url=utils.get_url("organization"),
         data={"error": f"Organization {name} already exists"},
     )
コード例 #16
0
 def assert_get_org_by_tag_invalid(client, tag):
     with pytest.raises(StatusCodeException) as e:
         client.organizations.get_organization_by_tag(tag)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=503,
         method="GET",
         url=utils.get_url(f"organization/{tag}"),
         data={"error": "Failed to retrieve organization info"},
     )
コード例 #17
0
 def assert_org_delete_fails(org):
     with pytest.raises(StatusCodeException) as e:
         org.delete()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=401,
         method="DELETE",
         url=utils.get_url("organization"),
         data={"msg": "Missing Authorization Header"},
     )
コード例 #18
0
 def assert_org_list_projects_forbidden(org):
     with pytest.raises(StatusCodeException) as e:
         org.list_projects()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=403,
         method="GET",
         url=utils.get_url(f"organization/{org.tag}"),
         data={
             "error":
             "You are not authorized to access this resource: system_admin required."
         },
     )
コード例 #19
0
 def assert_list_orgs_forbidden(client):
     with pytest.raises(StatusCodeException) as e:
         client.organizations.list_organizations()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=403,
         method="GET",
         url=utils.get_url("organization/all"),
         data={
             "error":
             "You are not authorized to access this resource: system_admin required."
         },
     )
コード例 #20
0
 def assert_org_delete_forbidden(org):
     with pytest.raises(StatusCodeException) as e:
         org.delete()
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=403,
         method="DELETE",
         url=utils.get_url("organization"),
         data={
             "error":
             "You are not authorized to access this resource: system_admin required."
         },
     )
コード例 #21
0
 def assert_change_password_invalid(client, old_password, new_password):
     with pytest.raises(StatusCodeException) as e:
         client.users.change_password(old_password, new_password)
     utils.assert_status_code_exception(
         exception=e.value,
         status_code=400,
         method="POST",
         url=utils.get_url("changepwd"),
         data={
             "error":
             "Unable to update password: Old password does not match."
         },
     )
コード例 #22
0
def test_delete_scenario(data, client, project, model_info):
    assert client.scenarios.list_scenarios(project) == []
    name = str(uuid.uuid4())
    description = str(uuid.uuid4())
    scenario = client.scenarios.create_scenario(
        project=project,
        name=name,
        model_info=model_info,
        description=description,
        tunings=[],
    )
    fetched = client.scenarios.list_scenarios(project)
    fetched_scenario = fetched[0]
    scenario.delete()
    assert client.scenarios.list_scenarios(project) == []
    with pytest.raises(StatusCodeException) as ex:
        fetched_scenario.delete()
    utils.assert_status_code_exception(
        exception=ex.value,
        status_code=404,
        method="DELETE",
        url=utils.get_url("scenarios"),
        data={"error": f"Scenario {fetched_scenario.tid} not found"},
    )