Skip to content

Commit

Permalink
Add test for throwing RequestFailedException from Python
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone committed Jul 31, 2024
1 parent 0f6a8e2 commit 1f47b08
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
40 changes: 40 additions & 0 deletions python/test/Ice/exceptions/AllTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,4 +839,44 @@ def allTests(helper, communicator):
pass
print("ok")

sys.stdout.write("testing exceptions in request failed exception... ")
sys.stdout.flush()
try:
thrower.throwRequestFailedException(
"Ice.ObjectNotExistException",
Ice.Identity("name", "category"),
"facet",
"operation")
test(False)
except Ice.ObjectNotExistException as ex:
test(ex.id == Ice.Identity("name", "category"))
test(ex.facet == "facet")
test(ex.operation == "operation")

try:
thrower.throwRequestFailedException(
"Ice.OperationNotExistException",
Ice.Identity("name", "category"),
"facet",
"operation")
test(False)
except Ice.OperationNotExistException as ex:
test(ex.id == Ice.Identity("name", "category"))
test(ex.facet == "facet")
test(ex.operation == "operation")

try:
thrower.throwRequestFailedException(
"Ice.FacetNotExistException",
Ice.Identity("name", "category"),
"facet",
"operation")
test(False)
except Ice.FacetNotExistException as ex:
test(ex.id == Ice.Identity("name", "category"))
test(ex.facet == "facet")
test(ex.operation == "operation")


print("ok")
return thrower
8 changes: 8 additions & 0 deletions python/test/Ice/exceptions/ServerAMD.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ def throwMarshalException(self, current):
return Ice.Future.completed((0, ""))
return Ice.Future.completed(None)

def throwRequestFailedException(self, typeName, id, facet, operation, current):
if typeName == "Ice.ObjectNotExistException":
raise Ice.ObjectNotExistException(id, facet, operation)
elif typeName == "Ice.FacetNotExistException":
raise Ice.FacetNotExistException(id, facet, operation)
elif typeName == "Ice.OperationNotExistException":
raise Ice.OperationNotExistException(id, facet, operation)


class ServerAMD(TestHelper):
def run(self, args):
Expand Down
3 changes: 3 additions & 0 deletions python/test/Ice/exceptions/Test.ice
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include "Ice/BuiltinSequences.ice"
#include "Ice/Identity.ice"

module Test
{
Expand Down Expand Up @@ -73,6 +74,8 @@ interface Thrower
void throwAfterException() throws A;

int throwMarshalException(out int p);

void throwRequestFailedException(string type, Ice::Identity id, string facet, string operation);
}

interface WrongOperation
Expand Down
8 changes: 8 additions & 0 deletions python/test/Ice/exceptions/TestI.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,11 @@ def throwMarshalException(self, current):
return ("", 0)
if "param" in current.ctx:
return (0, "")

def throwRequestFailedException(self, typeName, id, facet, operation, current):
if typeName == "Ice.ObjectNotExistException":
raise Ice.ObjectNotExistException(id, facet, operation)
elif typeName == "Ice.FacetNotExistException":
raise Ice.FacetNotExistException(id, facet, operation)
elif typeName == "Ice.OperationNotExistException":
raise Ice.OperationNotExistException(id, facet, operation)

0 comments on commit 1f47b08

Please sign in to comment.