Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blitz gateway unit tests #17

Merged
merged 6 commits into from Sep 20, 2019
Merged

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Sep 5, 2019

Tests that some BlitzGateway Object methods return unicode and some return string.
See https://docs.openmicroscopy.org/omero/5.5.1/developers/PythonBlitzGateway.html#unicode

For a deeper discussion of Unicode handling in BlitzGateway, see ome/openmicroscopy#5400

Tests BlitzObjectWrapper.__getattr__ returning unicode strings, enums, values/units and wrapper objects.
NB: Tests pass with the current behaviour of the BlitzGateway, with some methods returning strings and some returning unicode. With Python3, that should all go away ;).

@will-moore will-moore changed the title Add methods to test BlitzGateway unicode handling blitz gateway unit tests Sep 5, 2019
@will-moore
Copy link
Member Author

@joshmoore Not sure if this travis failure is due to this PR or something else changing?

                try:
>                   g = g[p]
E                   TypeError: string indices must be integers, not str

target/omero/scripts.py:577: TypeError
----------------------------- Captured stderr call -----------------------------
DEBUG:omero.util.TempFileManager:Added file /root/omero/tmp/omero_root/68/omero5T8aJl.tmp
------------------------------ Captured log call -------------------------------
DEBUG    omero.util.TempFileManager:temp_files.py:259 Added file /root/omero/tmp/omero_root/68/omero5T8aJl.tmp
=========================== short test summary info ============================
FAILED test/unit/scriptstest/test_parse.py::TestParse::testGroupingWithMainExtraDot
FAILED test/unit/scriptstest/test_parse.py::TestParse::testGroupingWithMain
======== 2 failed, 784 passed, 134 skipped, 1 xfailed in 45.91 seconds =========
ERROR: InvocationError for command /src/.tox/py27/bin/pytest -n8 -m 'not broken' -rf test/unit/clitest/ test/unit/fstest/ test/unit/gatewaytest/ test/unit/scriptstest/ (exited with code 1)
___________________________________ summary ____________________________________
ERROR:   py27: commands failed
The command '/bin/sh -c /v/bin/tox' returned a non-zero code: 1
travis_time:end:03391cfb:start=1567703651938332760,finish=1567703779897023737,duration=127958690977,event=script
�[0K�[31;1mThe command "docker build -t test ." exited with 1.�[0m

@joshmoore
Copy link
Member

I don't know either. I ran into it late yesterday while comparing the py27 and py36 tests.

@joshmoore
Copy link
Member

Otherwise, tests look generally good. Don't know if they will cover all the edge cases but who does... Do you have an example of what would make one of these tests fail?

@will-moore
Copy link
Member Author

Changing logic of BlitzObjectWrapper.__getattr__() will break tests. E.g.

This causes 2 tests to fail since they expect unicode:

@@ -1289,7 +1289,7 @@ class BlitzObjectWrapper (object):
                     rv = getattr(self._obj, attrName)
                     if hasattr(rv, 'val'):
                         if isinstance(rv.val, StringType):
-                            return rv.val.decode('utf8')
+                            return rv.val

Removing BlitzObjectWrapper.getName() causes 4 tests to fail because then it uses __getattr__ to lookup the name from the underlying object and this returns unicode instead of String.

$ pytest test/unit/test_gateway.py
...
platform darwin -- Python 2.7.16, pytest-4.6.5, py-1.8.0, pluggy-0.12.0
rootdir: /Users/willadmin/Desktop/PYTHON/omero-py, inifile: pytest.ini
collected 13 items                                                                                                                                                               

test/unit/test_gateway.py .F.F.FF......

@joshmoore
Copy link
Member

#17 (comment)

              g = g[p]

E TypeError: string indices must be integers, not str

I fixed this in my py3 branch: d0ddc7e

I'll cherry-pick it here and see if we can go green.

The previous method seemed to have edge cases that led
to failures based on the ordering of the parameters.
@joshmoore
Copy link
Member

@will-moore : can you take a look at the last commit? If you're happy with it, I'd say let's get this in. (As far as I could tell group_params wasn't used anywhere anyway)

@will-moore
Copy link
Member Author

Looks good, thanks

@joshmoore joshmoore merged commit f16622e into ome:master Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants