/components/tools/OmeroPy/test/cmdtest/example.py

https://github.com/cneves/openmicroscopy
Python | 56 lines | 29 code | 17 blank | 10 comment | 1 complexity | 2086cd15a0e292fac66f6d21147b8815 MD5 | raw file
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Copyright (C) 2011 Glencoe Software, Inc. All Rights Reserved.
  5. # Use is subject to license terms supplied in LICENSE.txt
  6. #
  7. """
  8. Example test of the new omero.cmd API
  9. """
  10. from integration.library import ITest
  11. class CmdTest(ITest):
  12. def testConnection(self):
  13. import Ice
  14. ic = Ice.initialize()
  15. from omero_cmd import SessionI
  16. session = Session() # username, password, host, etc from config
  17. session.connect()
  18. session.disconnect()
  19. def testCommands(self):
  20. sess = getSession()
  21. client = SyncClient(session)
  22. create = Create(type="Project", {"name": "test"})
  23. response = client.call(create) # , loop=10
  24. modify = Modify(type="Project", id=response.id, {"name": "test2"})
  25. sess.submit(modify)
  26. query = ListQuery("select d from Dataset d")
  27. response = client.call(query)
  28. link = Link(parent="Project:1", child=response.list[0])
  29. handle = sess.submit(link)
  30. pop = PopStatus(10, include=[FAILURE])
  31. response = client.call(pop) # Removes from queue
  32. findHandles = FindHandles(include=[DONE], exclude=[SUCCESS])
  33. response = client.call(findHandles)
  34. response = sess.call(ListCommands())
  35. # Multi-call
  36. requests = RequestList(list=[ListCommands(), ListCommands(),ListCommands()])
  37. responses = sess.call(req_list).list
  38. if __name__ == '__main__':
  39. unittest.main()