Skip to content

Commit

Permalink
Merge pull request ome#2317 from ximenesuk/flake8-sub-fixes
Browse files Browse the repository at this point in the history
Flake8 fixes of integration tests
  • Loading branch information
joshmoore committed Apr 25, 2014
2 parents 2caa27b + 626c6e6 commit 5c4f7e0
Show file tree
Hide file tree
Showing 14 changed files with 412 additions and 242 deletions.
18 changes: 15 additions & 3 deletions components/tools/OmeroPy/test/integration/cmdtest/test_chgrp.py
Expand Up @@ -2,9 +2,22 @@
# -*- coding: utf-8 -*-

#
# Copyright (C) 2011-2013 Glencoe Software, Inc. All Rights Reserved.
# Copyright (C) 2011-2014 Glencoe Software, Inc. All Rights Reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

"""
Test of the omero.cmd.Chgrp Request type.
Expand All @@ -16,13 +29,12 @@
from omero.callbacks import CmdCallbackI


class ChgrpTest(lib.ITest):
class TestChgrp(lib.ITest):

def testChgrpImage(self):

# One user in two groups
client, exp = self.new_client_and_user()
grp = self.new_group([exp])
update = client.sf.getUpdateService()
query = client.sf.getQueryService()

Expand Down
30 changes: 20 additions & 10 deletions components/tools/OmeroPy/test/integration/cmdtest/test_columbus.py
Expand Up @@ -2,9 +2,22 @@
# -*- coding: utf-8 -*-

#
# Copyright (C) 2011-2013 Glencoe Software, Inc. All Rights Reserved.
# Copyright (C) 2011-2014 Glencoe Software, Inc. All Rights Reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

"""
Test of the omero.cmd.Chgrp and Chown Request types
Expand All @@ -23,13 +36,10 @@
"""

import omero
import test.integration.library as lib

from omero.callbacks import CmdCallbackI


class ColumbusTest(lib.ITest):
class TestColumbus(lib.ITest):
"""
The following tests all assume the following
user configuration:
Expand All @@ -43,19 +53,19 @@ class ColumbusTest(lib.ITest):
def userconfig(self, perms="rwr---"):
self.group_a = self.new_group(perms=perms)
self.client_A, self.user_A = \
self.new_client_and_user(group=self.group_a, admin=True)
self.new_client_and_user(group=self.group_a, admin=True)
self.client_B, self.user_B = \
self.new_client_and_user(group=self.group_a, admin=False)
self.new_client_and_user(group=self.group_a, admin=False)

self.group_b = self.new_group(perms=perms)
self.client_C, self.user_C = \
self.new_client_and_user(group=self.group_b, admin=True)
self.new_client_and_user(group=self.group_b, admin=True)
self.client_D, self.user_D = \
self.new_client_and_user(group=self.group_b, admin=False)
self.new_client_and_user(group=self.group_b, admin=False)

self.group_c = self.new_group(perms=perms)
self.client_E, self.user_E = \
self.new_client_and_user(group=self.group_c)
self.new_client_and_user(group=self.group_c)

def data(self, client):
up = client.sf.getUpdateService()
Expand Down
@@ -1,33 +1,46 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# Copyright (C) 2008-2014 Glencoe Software, Inc. All Rights Reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
# $Id$
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Copyright 2008-2013 Glencoe Software, Inc. All rights reserved.
# Use is subject to license terms supplied in LICENSE.txt
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import sys
import types

import omero, omero.scripts as sc
import omero
import omero.scripts as sc

client = sc.client("script_1", """
This is a test script used to test the basic parsing functionality
and attempts to interaction with the server
""",
#sc.Int("myint"),
sc.Long("mylong"),
sc.Bool("mybool"),
sc.String("mystring"),
sc.String("myoptional",optional=True)
)
sc.Int("myint"),
sc.Long("mylong"),
sc.Bool("mybool"),
sc.String("mystring"),
sc.String("myoptional", optional=True)
)

import os, sys, types
assert type(client) == types.TupleType
assert isinstance(client, types.TupleType)

self = sys.argv[0]
cfg = self.replace("py","cfg")
self = sys.argv[0]
cfg = self.replace("py", "cfg")

real_client = omero.client(["--Ice.Config=%s" % cfg])
parse_only = real_client.getProperty("omero.script.parse")
assert parse_only == "true"


This file was deleted.

@@ -1,19 +1,32 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# Copyright (C) 2008-2014 Glencoe Software, Inc. All Rights Reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

"""
Minimal script to test the {g,s}et{In,Out}put functionality
of omero.client
Copyright 2008-2013 Glencoe Software, Inc. All rights reserved.
Use is subject to license terms supplied in LICENSE.txt
"""

import omero.scripts

client = omero.scripts.client("test_harness")
pixelsID = client.getInput("pixelsID")
client.setOutput("newPixelsID",-1)


client.setOutput("newPixelsID", -1)
@@ -0,0 +1,44 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# Copyright (C) 2008-2014 Glencoe Software, Inc. All Rights Reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

"""
Harness for calling scripts via `omero script`
of omero.client
"""

import omero.cli
import test.integration.library as lib


def call(*args):
omero.cli.argv(["omero", "script"] + list(args))


class TestScriptsViaOmeroCli(lib.ITest):

def testDefinition(self):
call("test/scripts/definition.py",
"--Ice.Config=test/scripts/definition.cfg")

def testSimpleScript(self):
call("test/scripts/simple_script.py",
"--Ice.Config=test/scripts/simple_script.cfg")
@@ -1,17 +1,31 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# Copyright (C) 2010-2014 Glencoe Software, Inc. All Rights Reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

"""
Integration test demonstrating various script creation methods
Copyright 2010-2013 Glencoe Software, Inc. All rights reserved.
Use is subject to license terms supplied in LICENSE.txt
"""

import test.integration.library as lib
import pytest
import os, sys

import omero

Expand All @@ -20,39 +34,40 @@ class TestCoverage(lib.ITest):

def setup_method(self, method):
"""
getScripts returns official scripts, several of which are shipped with OMERO.
getScripts returns official scripts,
several of which are shipped with OMERO.
"""
lib.ITest.setup_method(self, method)
self.rs = self.root.sf.getScriptService()
self.us = self.client.sf.getScriptService()
assert len(self.rs.getScripts()) > 0
assert len(self.us.getScripts()) > 0
assert len(self.us.getUserScripts([])) == 0 # New user. No scripts
assert len(self.us.getUserScripts([])) == 0 # New user. No scripts

def testGetScriptWithDetails(self):
scriptList = self.us.getScripts()
script = scriptList[0]
scriptMap = self.us.getScriptWithDetails(script.id.val)

assert len(scriptMap) == 1
scriptText = scriptMap.keys()[0]
scriptObj = scriptMap.values()[0]

def testUploadAndScript(self):
scriptID = self.us.uploadScript("/OME/Foo.py", """if True:
import omero
import omero.grid as OG
import omero.rtypes as OR
import omero.scripts as OS
client = OS.client("testUploadScript")
print "done"
""")
scriptID = self.us.uploadScript(
"/OME/Foo.py",
"""if True:
import omero
import omero.grid as OG
import omero.rtypes as OR
import omero.scripts as OS
client = OS.client("testUploadScript")
print "done"
""")
return scriptID


def testUserCantUploadOfficalScript(self):
with pytest.raises(omero.SecurityViolation):
self.us.uploadOfficialScript( "/%s/fails.py" % self.uuid(),\
"""if True:
import omero
""")
self.us.uploadOfficialScript(
"/%s/fails.py" % self.uuid(),
"""if True:
import omero
""")

0 comments on commit 5c4f7e0

Please sign in to comment.