Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jburel committed Apr 2, 2024
1 parent 9638f97 commit 29ea024
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,62 @@ def testMiscellaneous(self, gatewaywrapper):
gatewaywrapper.loginAsUser()
assert gatewaywrapper.gateway.getUser().omeName == \
gatewaywrapper.USER.name

def testConnectUsingClient(self, gatewaywrapper):
gatewaywrapper.loginAsAdmin()
username = "connect_test_user6"
password = "foobar"
connect_test_user = dbhelpers.UserEntry(
username, password, firstname='User', lastname='ConnectUsingClient')
chmod_test_user.create(gatewaywrapper.gateway, dbhelpers.ROOT.passwd)
gatewaywrapper.doDisconnect()

client = omero.client()
client.createSession(user, password)
with BlitzGateway(client_obj=client) as conn:
assert client.connect(), "Cannot be connected"

def testConnectUsingClientNoSessionWithIdentity(self, gatewaywrapper):
gatewaywrapper.loginAsAdmin()
username = "connect_test_user7"
password = "foobar"
connect_test_user = dbhelpers.UserEntry(
username, password, firstname='User',
lastname='ConnectUsingClientNoSessionWithIdentity')
chmod_test_user.create(gatewaywrapper.gateway, dbhelpers.ROOT.passwd)
gatewaywrapper.doDisconnect()

client = omero.client()
with BlitzGateway(client_obj=client) as conn:
conn.setIdentity(user, password)
assert client.connect(), "Cannot be connected"

def testConnectUsingClientSessionWithoutIdentity(self, gatewaywrapper):
gatewaywrapper.loginAsAdmin()
username = "connect_test_user8"
password = "foobar"
connect_test_user = dbhelpers.UserEntry(
username, password, firstname='User',
lastname='ConnectUsingClientNoSessionWithoutIdentity')
chmod_test_user.create(gatewaywrapper.gateway, dbhelpers.ROOT.passwd)
gatewaywrapper.doDisconnect()

client = omero.client()
with BlitzGateway(client_obj=client) as conn:
assert client.connect() == False

def testSessionId(self, gatewaywrapper):
gatewaywrapper.loginAsAdmin()
username = "session_test_user"
password = "foobar"
connect_test_user = dbhelpers.UserEntry(
username, password, firstname='User',
lastname='sessionId')
chmod_test_user.create(gatewaywrapper.gateway, dbhelpers.ROOT.passwd)
gatewaywrapper.doDisconnect()

client = omero.client()
client.createSession(user, password)
sid = client.getSessionId()
with BlitzGateway(client_obj=client) as conn:
assert sid == conn.getSession().getUuid().val

0 comments on commit 29ea024

Please sign in to comment.