示例#1
0
    def testGrouping(self):
        SCRIPT = """if True:
            from omero.scripts import *
            c = client('testGrouping',
                Long('these', grouping="A.1"),
                Long('belong', grouping="A.2"),
                Long('together', grouping="A.3"))"""
        params = parse_text(SCRIPT)

        groupings = group_params(params)
        assert "these" == groupings["A"]["1"], str(groupings)
        assert "belong" == groupings["A"]["2"], str(groupings)
        assert "together" == groupings["A"]["3"], str(groupings)
    def testGrouping(self):
        SCRIPT = """if True:
            from omero.scripts import *
            c = client('testGrouping',
                Long('these', grouping="A.1"),
                Long('belong', grouping="A.2"),
                Long('together', grouping="A.3"))"""
        params = parse_text(SCRIPT)

        groupings = group_params(params)
        assert "these" == groupings["A"]["1"], str(groupings)
        assert "belong" == groupings["A"]["2"], str(groupings)
        assert "together" == groupings["A"]["3"], str(groupings)
示例#3
0
    def test2340(self):
        SCRIPT = """if True:
            from omero.scripts import *
            c = client('2340',
                Long('l', default=10))"""
        params = parse_text(SCRIPT)
        l = params.inputs["l"]
        assert None != l.prototype, str(l)

        # Copied from testUploadOfficialScript
        scriptLines = [
            "import omero", "from omero.rtypes import rstring, rlong",
            "import omero.scripts as scripts", "if __name__ == '__main__':",
            "    client = scripts.client('HelloWorld.py',"
            " 'Hello World example script',",
            "    scripts.Long('longParam', True, description='theDesc',"
            " min=rlong(1), max=rlong(10), values=[rlong(5)]) )",
            "    client.setOutput('returnMessage', rstring('Script ran"
            " OK!'))"
        ]
        params = parse_text("\n".join(scriptLines))
        l = params.inputs["longParam"]
        assert None != l.prototype, str(l)
    def testListOfType(self):
        SCRIPT = """
if True:
    import omero
    import omero.all
    from omero.rtypes import rstring, rlong
    import omero.scripts as scripts
    client = scripts.client(
        'HelloWorld.py', 'Hello World example script',
        scripts.List('Image_List').ofType(omero.model.ImageI))
    client.setOutput('returnMessage', rstring('Script ran OK!'))"""
        params = parse_text(SCRIPT)
        listParam = params.inputs["Image_List"]
        assert isinstance(listParam.prototype.val[0].val, omero.model.Image)
示例#5
0
    def testListOfType(self):
        SCRIPT = """
if True:
    import omero
    import omero.all
    from omero.rtypes import rstring, rlong
    import omero.scripts as scripts
    client = scripts.client(
        'HelloWorld.py', 'Hello World example script',
        scripts.List('Image_List').ofType(omero.model.ImageI))
    client.setOutput('returnMessage', rstring('Script ran OK!'))"""
        params = parse_text(SCRIPT)
        listParam = params.inputs["Image_List"]
        assert isinstance(listParam.prototype.val[0].val, omero.model.Image)
    def test2340(self):
        SCRIPT = """if True:
            from omero.scripts import *
            c = client('2340',
                Long('l', default=10))"""
        params = parse_text(SCRIPT)
        l = params.inputs["l"]
        assert None != l.prototype, str(l)

        # Copied from testUploadOfficialScript
        scriptLines = [
            "import omero",
            "from omero.rtypes import rstring, rlong",
            "import omero.scripts as scripts",
            "if __name__ == '__main__':",
            "    client = scripts.client('HelloWorld.py',"
            " 'Hello World example script',",
            "    scripts.Long('longParam', True, description='theDesc',"
            " min=rlong(1), max=rlong(10), values=[rlong(5)]) )",
            "    client.setOutput('returnMessage', rstring('Script ran"
            " OK!'))"]
        params = parse_text("\n".join(scriptLines))
        l = params.inputs["longParam"]
        assert None != l.prototype, str(l)
示例#7
0
    def testObjectTypeWithDefault(self):
        SCRIPT = """
if True:
    import omero
    import omero.all
    import omero.scripts as scripts
    from omero.rtypes import robject

    client = scripts.client(
        'RObjectExampleWithDefault.py', 'Example script passing an robject',
        scripts.Object('objParam', True, description='theDesc',
                       default=omero.model.ImageI()))"""
        params = parse_text(SCRIPT)
        objParam = params.inputs["objParam"]
        assert isinstance(objParam.prototype, omero.RObject)
        assert isinstance(objParam.prototype.val, omero.model.ImageI)
    def testTicket2323(self):
        SCRIPT = """
if True:
    import omero
    from omero.rtypes import rstring, rlong
    import omero.scripts as scripts
    client = scripts.client(
        'HelloWorld.py', 'Hello World example script',
        scripts.Long('longParam', True, description='theDesc', min=long(1),
        max=long(10), values=[rlong(5)]) )
    client.setOutput('returnMessage', rstring('Script ran OK!'))"""
        params = parse_text(SCRIPT)
        longParam = params.inputs["longParam"]
        assert 1 == unwrap(longParam.min), str(longParam.min)
        assert 10 == unwrap(longParam.max), str(longParam.max)
        assert [5] == unwrap(longParam.values), str(longParam.values)
示例#9
0
    def testTicket2323(self):
        SCRIPT = """
if True:
    import omero
    from omero.rtypes import rstring, rlong
    import omero.scripts as scripts
    client = scripts.client(
        'HelloWorld.py', 'Hello World example script',
        scripts.Long('longParam', True, description='theDesc', min=long(1),
        max=long(10), values=[rlong(5)]) )
    client.setOutput('returnMessage', rstring('Script ran OK!'))"""
        params = parse_text(SCRIPT)
        longParam = params.inputs["longParam"]
        assert 1 == unwrap(longParam.min), str(longParam.min)
        assert 10 == unwrap(longParam.max), str(longParam.max)
        assert [5] == unwrap(longParam.values), str(longParam.values)
示例#10
0
    def testObjectTypeWithDefault(self):
        SCRIPT = """
if True:
    import omero
    import omero.all
    import omero.scripts as scripts
    from omero.rtypes import robject

    client = scripts.client(
        'RObjectExampleWithDefault.py', 'Example script passing an robject',
        scripts.Object('objParam', True, description='theDesc',
                       default=omero.model.ImageI()))"""
        params = parse_text(SCRIPT)
        objParam = params.inputs["objParam"]
        assert isinstance(objParam.prototype, omero.RObject)
        assert isinstance(objParam.prototype.val, omero.model.ImageI)
示例#11
0
    def testGroupingWithMain(self):
        SCRIPT = """if True:
            from omero.scripts import *
            c = client('testGrouping',
                Bool('checkbox', grouping="A"),
                Long('these', grouping="A.1"),
                Long('belong', grouping="A.2"),
                Long('together', grouping="A.3"))"""
        params = parse_text(SCRIPT)

        groupings = group_params(params)
        try:
            assert "checkbox" == groupings["A"][""], str(groupings)
            assert "these" == groupings["A"]["1"], str(groupings)
            assert "belong" == groupings["A"]["2"], str(groupings)
            assert "together" == groupings["A"]["3"], str(groupings)
        except KeyError:
            assert False, str(groupings)
示例#12
0
 def testValidateRoiMovieCall(self):
     SCRIPT = """if True:
         from omero.rtypes import rlong, rstring
         import omero.scripts as scripts
         scripts.client('Movie_ROI_Figure.py',
             scripts.String("Data_Type", values=[rstring('Image')]),
             scripts.List("IDs").ofType(rlong(0)),
             scripts.String("Image_Labels")
         )"""
     params = parse_text(SCRIPT)
     inputs = {
         "Merged_Colours": wrap(['Red', 'Green']),
         "Image_Labels": wrap("Datasets"),
         "Data_Type": wrap("Image"),
         "IDs": rlist([rlong(1)])
     }
     errors = validate_inputs(params, inputs)
     assert "" == errors, errors
示例#13
0
    def testGroupingWithMain(self):
        SCRIPT = """if True:
            from omero.scripts import *
            c = client('testGrouping',
                Bool('checkbox', grouping="A"),
                Long('these', grouping="A.1"),
                Long('belong', grouping="A.2"),
                Long('together', grouping="A.3"))"""
        params = parse_text(SCRIPT)

        groupings = group_params(params)
        try:
            assert "checkbox" == groupings["A"][""], str(groupings)
            assert "these" == groupings["A"]["1"], str(groupings)
            assert "belong" == groupings["A"]["2"], str(groupings)
            assert "together" == groupings["A"]["3"], str(groupings)
        except KeyError:
            assert False, str(groupings)
示例#14
0
    def testObjectType(self):
        SCRIPT = """
if True:
    import omero
    import omero.all
    import omero.scripts as scripts
    from omero.rtypes import robject

    client = scripts.client(
        'RObjectExample.py', 'Example script passing an robject',
        scripts.Object('objParam', True, description='theDesc'))"""
        params = parse_text(SCRIPT)
        objParam = params.inputs["objParam"]
        assert isinstance(objParam.prototype, omero.RObject)
        assert objParam.prototype.val is None

        rv = parse_inputs(["objParam=OriginalFile:1"], params)
        assert rv["objParam"].val.__class__ == omero.model.OriginalFileI
        assert rv["objParam"].val.id.val == 1
示例#15
0
    def testObjectType(self):
        SCRIPT = """
if True:
    import omero
    import omero.all
    import omero.scripts as scripts
    from omero.rtypes import robject

    client = scripts.client(
        'RObjectExample.py', 'Example script passing an robject',
        scripts.Object('objParam', True, description='theDesc'))"""
        params = parse_text(SCRIPT)
        objParam = params.inputs["objParam"]
        assert isinstance(objParam.prototype, omero.RObject)
        assert objParam.prototype.val is None

        rv = parse_inputs(["objParam=OriginalFile:1"], params)
        assert rv["objParam"].val.__class__ == omero.model.OriginalFileI
        assert rv["objParam"].val.id.val == 1
示例#16
0
 def parse_list(self, SCRIPT):
     params = parse_text(SCRIPT)
     l = params.inputs["l"]
     assert l.useDefault, str(l)
     assert ["a"] == unwrap(l.prototype)
示例#17
0
 def parse_list(self, SCRIPT):
     params = parse_text(SCRIPT)
     l = params.inputs["l"]
     assert l.useDefault, str(l)
     assert ["a"] == unwrap(l.prototype)