Ejemplo n.º 1
0
    def testRMapRMapRInt(self):
        params = omero.grid.JobParams()
        param = omero.grid.Param()
        param.prototype = rmap({"b": rmap({"c": rint(0)})})
        params.inputs = {"a": param}

        input = rmap({"b": rmap({"c": rint(1)})})
        inputs = {"a": input}
        assert "" == validate_inputs(params, inputs)
    def testRMapRMapRInt(self):
        params = omero.grid.JobParams()
        param = omero.grid.Param()
        param.prototype = rmap({"b": rmap({"c": rint(0)})})
        params.inputs = {"a": param}

        input = rmap({"b": rmap({"c": rint(1)})})
        inputs = {"a": input}
        assert "" == validate_inputs(params, inputs)
Ejemplo n.º 3
0
 def testGetAttrWorks(self):
     rbool(True).val
     rdouble(0.0).val
     rfloat(0.0).val
     rint(0).val
     rlong(0).val
     rtime(0).val
     rinternal(None).val
     robject(None).val
     rstring("").val
     rclass("").val
     rarray().val
     rlist().val
     rset().val
     rmap().val
Ejemplo n.º 4
0
 def testGetAttrWorks(self):
     rbool(True).val
     rdouble(0.0).val
     rfloat(0.0).val
     rint(0).val
     rlong(0).val
     rtime(0).val
     rinternal(None).val
     robject(None).val
     rstring("").val
     rclass("").val
     rarray().val
     rlist().val
     rset().val
     rmap().val
Ejemplo n.º 5
0
    def testPingStdout(self):
        p = self._getProcessor()
        params = p.params()
        assert params.stdoutFormat

        process = p.execute(rmap({}))
        self.assertSuccess(p, process)
Ejemplo n.º 6
0
 def testPingViaISCript(self):
     p = self._getProcessor()
     input = rmap({})
     input.val["a"] = rlong(2)
     input.val["b"] = rstring("d")
     process = p.execute(input)
     output = self.assertSuccess(p, process)
     assert output.val["a"].val == 2
Ejemplo n.º 7
0
    def testMapCreationEqualsHash(self):

        id = rlong(1)
        map_notnull1 = rmap({"ids": id})
        map_notnull2 = rmap({"ids": id})
        # Equals based on content
        assert map_notnull1 == map_notnull2

        # But content is copied!
        assert not map_notnull1.getValue() is map_notnull2.getValue()

        map_null1 = rmap()
        map_null2 = rmap(None)
        map_null3 = rmap(**{})

        # All different since the contents are mutable.
        assert map_null1 is not map_notnull1
        assert map_null1 is not map_null2  # TODO Different with maps
        assert map_null1 is not map_null3  # TODO Different with maps
Ejemplo n.º 8
0
    def testMapCreationEqualsHash(self):

        id = rlong(1L)
        map_notnull1 = rmap({"ids": id})
        map_notnull2 = rmap({"ids": id})
        # Equals based on content
        assert map_notnull1 == map_notnull2

        # But content is copied!
        assert not map_notnull1.getValue() is map_notnull2.getValue()

        map_null1 = rmap()
        map_null2 = rmap(None)
        map_null3 = rmap(**{})

        # All different since the contents are mutable.
        assert map_null1 is not map_notnull1
        assert map_null1 is not map_null2  # TODO Different with maps
        assert map_null1 is not map_null3  # TODO Different with maps
Ejemplo n.º 9
0
 def testProcessShutdownOneway(self):
     p = self._getProcessor()
     process = p.execute(rmap({}))
     oneway = omero.grid.ProcessPrx.uncheckedCast(process.ice_oneway())
     oneway.shutdown()
     # Depending on what's faster this may or may not throw
     try:
         p.getResults(process)
         assert process.poll()
         p.getResults(process)
     except omero.ServerError:
         pass
Ejemplo n.º 10
0
    def testProcessCallback(self):

        callback = CallbackI()

        id = self.client.getCommunicator().stringToIdentity(str(uuid.uuid4()))
        cb = self.client.getAdapter().add(callback, id)
        cb = omero.grid.ProcessCallbackPrx.uncheckedCast(cb)
        p = self._getProcessor()
        params = p.params()
        assert params.stdoutFormat

        process = p.execute(rmap({}))
        process.registerCallback(cb)
        self.assertSuccess(p, process)

        assert len(callback.finish) > 0
Ejemplo n.º 11
0
 def testProcessorStop(self):
     p = self._getProcessor()
     p.execute(rmap({}))
     p.stop()
Ejemplo n.º 12
0
    def testProcessShutdown(self):
        p = self._getProcessor()
        process = p.execute(rmap({}))
        process.shutdown()

        p.getResults(process)
Ejemplo n.º 13
0
 def testPassThroughNoneAndRTypes(self):
     """
     To prevent having to check for isintance(int,...) or
     isintance(RInt,...) all over the place, the static methods
     automatically check for acceptable
     types and simply pass them through. Similarly, the primitive types all
     check for None and return a null RType if necessary.
     """
     # Bool
     assert None == rbool(None)
     assert rbool(True) == rbool(rbool(True))
     assert rbool(True) == rbool(1)
     assert rbool(False) == rbool(0)
     # Double
     assert None == rdouble(None)
     assert rdouble(0.0) == rdouble(rdouble(0.0))
     assert rdouble(0.0) == rdouble(rdouble(0))
     assert rdouble(0.0) == rdouble(rdouble("0.0"))
     pytest.raises(ValueError, lambda: rdouble("string"))
     # Float
     assert None == rfloat(None)
     assert rfloat(0.0) == rfloat(rfloat(0.0))
     assert rfloat(0.0) == rfloat(rfloat(0))
     assert rfloat(0.0) == rfloat(rfloat("0.0"))
     pytest.raises(ValueError, lambda: rfloat("string"))
     # Long
     assert None == rlong(None)
     assert rlong(0) == rlong(rlong(0))
     assert rlong(0) == rlong(rlong(0.0))
     assert rlong(0) == rlong(rlong("0"))
     pytest.raises(ValueError, lambda: rlong("string"))
     # Time
     assert None == rtime(None)
     assert rtime(0) == rtime(rtime(0))
     assert rtime(0) == rtime(rtime(0.0))
     assert rtime(0) == rtime(rtime("0"))
     pytest.raises(ValueError, lambda: rtime("string"))
     # Int
     assert None == rint(None)
     assert rint(0) == rint(rint(0))
     assert rint(0) == rint(rint(0.0))
     assert rint(0) == rint(rint("0"))
     pytest.raises(ValueError, lambda: rint("string"))
     #
     # Starting here handling of null is different.
     #
     # String
     assert rstring("") == rstring(None)
     assert rstring("a") == rstring(rstring("a"))
     assert rstring("0") == rstring(0)
     # Class
     assert rclass("") == rclass(None)
     assert rclass("c") == rclass(rclass("c"))
     pytest.raises(ValueError, lambda: rclass(0))
     # Internal
     internal = omero.Internal()
     assert rinternal(None) == rinternal(None)
     assert rinternal(internal) == rinternal(rinternal(internal))
     pytest.raises(ValueError, lambda: rinternal("string"))
     # Object
     obj = omero.model.ImageI()
     assert robject(None) == robject(None)
     assert robject(obj) == robject(robject(obj))
     pytest.raises(ValueError, lambda: robject("string"))
     #
     # Same does not hold for collections
     #
     # Array
     assert rarray([]) == rarray(None)
     # assert rarray(obj) == rarray(rarray(obj))
     # pytest.raises(ValueError, lambda : rarray("string"))
     # List
     assert rlist([]) == rlist(None)
     # assert rlist(obj) == rlist(rlist(obj))
     # pytest.raises(ValueError, lambda : rlist("string"))
     # Set
     assert rset([]) == rset(None)
     # assert rset(obj) == rset(rset(obj))
     # pytest.raises(ValueError, lambda : rset("string"))
     # Map
     assert rmap({}) == rmap(None)
Ejemplo n.º 14
0
    def testUnwrap(self):
        # NUMS plain
        assert 0 == unwrap(0)
        assert 1 == unwrap(1)
        assert 0.0 == unwrap(0.0)
        assert 1.0 == unwrap(1.0)
        # NUMS rtyped
        assert 0 == unwrap(rint(0))
        assert 0 == unwrap(rlong(0))
        assert 1 == unwrap(rint(1))
        assert 1 == unwrap(rlong(1))
        assert 0.0 == unwrap(rfloat(0.0))
        assert 0.0 == unwrap(rdouble(0.0))
        assert 1.0 == unwrap(rfloat(1.0))
        assert 1.0 == unwrap(rdouble(1.0))

        # STRINGS
        assert "" == unwrap("")
        assert "str" == unwrap("str")

        # BOOL
        assert True == unwrap(True)
        assert False == unwrap(False)
        assert True == unwrap(rbool(True))
        assert False == unwrap(rbool(False))

        # TIME
        # Bit odd, do we want the long for time, or transformed?
        assert 0 == unwrap(rtime(0))
        assert 1 == unwrap(rtime(1))

        # CLASS
        # same for class, should we map it?
        assert "k" == unwrap(rclass("k"))

        # INTERNAL
        color = omero.Color()
        assert color == unwrap(rinternal(color))

        # OBJECT
        image = omero.model.ImageI()
        assert image == unwrap(robject(image))

        # COLLECTIONS
        # empty
        assert [] == unwrap([])
        assert {} == unwrap({})
        assert set() == unwrap(set())
        # plain in collection
        assert [1] == unwrap([1])
        # rtype in collection
        assert [1] == unwrap([rint(1)])
        assert {"a": 1} == unwrap({"a": 1})
        # plain in rcollection ILLEGAL
        # assert [1] == unwrap(rlist([1]))
        # assert {"a":1} == unwrap(rmap({"a":1}))
        # rtype in rcollection
        assert [1] == unwrap(rlist([rint(1)]))
        assert {"a": 1} == unwrap(rmap({"a": rint(1)}))
        # rtype keys ILLEGAL
        # assert {"a":1} == unwrap(rmap({rstring("a"):rint(1)}))
        # recursion, ticket:1977
        m1 = rmap({"a": rint(1)})
        m1.val["m1"] = m1
        m2 = {"a": 1}
        m2["m1"] = m2
        unwrap(m1)
        assert m2["a"] == unwrap(m1)["a"]
        # Can't compare directly "maximum recursion depth exceeded in cmp"
        assert type(m2["m1"]) == type(unwrap(m1)["m1"])
Ejemplo n.º 15
0
 def testPassThroughNoneAndRTypes(self):
     """
     To prevent having to check for isintance(int,...) or
     isintance(RInt,...) all over the place, the static methods
     automatically check for acceptable
     types and simply pass them through. Similarly, the primitive types all
     check for None and return a null RType if necessary.
     """
     # Bool
     assert None == rbool(None)
     assert rbool(True) == rbool(rbool(True))
     assert rbool(True) == rbool(1)
     assert rbool(False) == rbool(0)
     # Double
     assert None == rdouble(None)
     assert rdouble(0.0) == rdouble(rdouble(0.0))
     assert rdouble(0.0) == rdouble(rdouble(0))
     assert rdouble(0.0) == rdouble(rdouble("0.0"))
     pytest.raises(ValueError, lambda: rdouble("string"))
     # Float
     assert None == rfloat(None)
     assert rfloat(0.0) == rfloat(rfloat(0.0))
     assert rfloat(0.0) == rfloat(rfloat(0))
     assert rfloat(0.0) == rfloat(rfloat("0.0"))
     pytest.raises(ValueError, lambda: rfloat("string"))
     # Long
     assert None == rlong(None)
     assert rlong(0) == rlong(rlong(0))
     assert rlong(0) == rlong(rlong(0.0))
     assert rlong(0) == rlong(rlong("0"))
     pytest.raises(ValueError, lambda: rlong("string"))
     # Time
     assert None == rtime(None)
     assert rtime(0) == rtime(rtime(0))
     assert rtime(0) == rtime(rtime(0.0))
     assert rtime(0) == rtime(rtime("0"))
     pytest.raises(ValueError, lambda: rtime("string"))
     # Int
     assert None == rint(None)
     assert rint(0) == rint(rint(0))
     assert rint(0) == rint(rint(0.0))
     assert rint(0) == rint(rint("0"))
     pytest.raises(ValueError, lambda: rint("string"))
     #
     # Starting here handling of null is different.
     #
     # String
     assert rstring("") == rstring(None)
     assert rstring("a") == rstring(rstring("a"))
     assert rstring("0") == rstring(0)
     # Class
     assert rclass("") == rclass(None)
     assert rclass("c") == rclass(rclass("c"))
     pytest.raises(ValueError, lambda: rclass(0))
     # Internal
     internal = omero.Internal()
     assert rinternal(None) == rinternal(None)
     assert rinternal(internal) == rinternal(rinternal(internal))
     pytest.raises(ValueError, lambda: rinternal("string"))
     # Object
     obj = omero.model.ImageI()
     assert robject(None) == robject(None)
     assert robject(obj) == robject(robject(obj))
     pytest.raises(ValueError, lambda: robject("string"))
     #
     # Same does not hold for collections
     #
     # Array
     assert rarray([]) == rarray(None)
     # assert rarray(obj) == rarray(rarray(obj))
     # pytest.raises(ValueError, lambda : rarray("string"))
     # List
     assert rlist([]) == rlist(None)
     # assert rlist(obj) == rlist(rlist(obj))
     # pytest.raises(ValueError, lambda : rlist("string"))
     # Set
     assert rset([]) == rset(None)
     # assert rset(obj) == rset(rset(obj))
     # pytest.raises(ValueError, lambda : rset("string"))
     # Map
     assert rmap({}) == rmap(None)
Ejemplo n.º 16
0
 def testProcessorDetach(self):
     p = self._getProcessor()
     p.execute(rmap({}))
     p.setDetach(True)
     p.stop()
Ejemplo n.º 17
0
 def testCLI(self):
     p = self._getProcessor()
     input = rmap({})
     process = p.execute(input)
     stdout, stderr = self.assertIO(self.assertSuccess(p, process))
     print("STDOUT:\n%s\nSTDERR:\n%s\n" % (stdout, stderr))
Ejemplo n.º 18
0
    def testUnwrap(self):
        # NUMS plain
        assert 0 == unwrap(0)
        assert 1 == unwrap(1)
        assert 0.0 == unwrap(0.0)
        assert 1.0 == unwrap(1.0)
        # NUMS rtyped
        assert 0 == unwrap(rint(0))
        assert 0 == unwrap(rlong(0))
        assert 1 == unwrap(rint(1))
        assert 1 == unwrap(rlong(1))
        assert 0.0 == unwrap(rfloat(0.0))
        assert 0.0 == unwrap(rdouble(0.0))
        assert 1.0 == unwrap(rfloat(1.0))
        assert 1.0 == unwrap(rdouble(1.0))

        # STRINGS
        assert "" == unwrap("")
        assert "str" == unwrap("str")

        # BOOL
        assert True == unwrap(True)
        assert False == unwrap(False)
        assert True == unwrap(rbool(True))
        assert False == unwrap(rbool(False))

        # TIME
        # Bit odd, do we want the long for time, or transformed?
        assert 0 == unwrap(rtime(0))
        assert 1 == unwrap(rtime(1))

        # CLASS
        # same for class, should we map it?
        assert "k" == unwrap(rclass("k"))

        # INTERNAL
        color = omero.Color()
        assert color == unwrap(rinternal(color))

        # OBJECT
        image = omero.model.ImageI()
        assert image == unwrap(robject(image))

        # COLLECTIONS
        # empty
        assert [] == unwrap([])
        assert {} == unwrap({})
        assert set() == unwrap(set())
        # plain in collection
        assert [1] == unwrap([1])
        # rtype in collection
        assert [1] == unwrap([rint(1)])
        assert {"a": 1} == unwrap({"a": 1})
        # plain in rcollection ILLEGAL
        # assert [1] == unwrap(rlist([1]))
        # assert {"a":1} == unwrap(rmap({"a":1}))
        # rtype in rcollection
        assert [1] == unwrap(rlist([rint(1)]))
        assert {"a": 1} == unwrap(rmap({"a": rint(1)}))
        # rtype keys ILLEGAL
        # assert {"a":1} == unwrap(rmap({rstring("a"):rint(1)}))
        # recursion, ticket:1977
        m1 = rmap({"a": rint(1)})
        m1.val["m1"] = m1
        m2 = {"a": 1}
        m2["m1"] = m2
        unwrap(m1)
        assert m2["a"] == unwrap(m1)["a"]
        # Can't compare directly "maximum recursion depth exceeded in cmp"
        assert type(m2["m1"]) == type(unwrap(m1)["m1"])