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

Django tests #270

Merged
merged 11 commits into from
Mar 4, 2018
Merged

Django tests #270

merged 11 commits into from
Mar 4, 2018

Conversation

will-moore
Copy link
Member

Looked at adding Django-based tests but this will clearly take a lot more setup than I am familiar with just now.
E.g. need to do similar to https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroWeb/setup.py#L24

    sys.path.insert(0, os.path.join("..", "target", "lib", "fallback"))
    LIB = os.path.join("..", "target", "lib", "python")
    sys.path.insert(0, LIB)
    OMEROWEB_LIB = os.path.join(LIB, "omeroweb")
    sys.path.insert(1, OMEROWEB_LIB)

Currently failing locally with

ImproperlyConfigured: Requested setting ROOT_URLCONF, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

@will-moore will-moore closed this Feb 8, 2018
@joshmoore joshmoore reopened this Feb 9, 2018
@joshmoore
Copy link
Member

./test/integration/test_figure_files.py:57:29: W292 no newline at end of file

@will-moore
Copy link
Member Author

========================== 5 failed in 11.61 seconds ===========================

Scripts tests are failing because scripts are not being copied over

        id = super(TestFigureScripts, self).get_script_by_name(path, name)
>       assert id > 0
E       assert -1 > 0

My Django test is failing with

        rsp = get(django_client, request_url, data, status_code, csrf)
>       assert rsp.get('Content-Type') == 'application/json'
E       AssertionError

but as I mentioned at will-moore#4 (comment) debugging this isn't so straight-forward given this test setup...

@jburel
Copy link
Member

jburel commented Feb 12, 2018

  • removing the empty app-build implies that the tests are now run when executing docker app. At that stage, the scripts have not copied. Copying the script will not solve the issue
  • swapping the order won't change anything
  • we are now at a point when we have tests to run under app and some under script.

@joshmoore
Copy link
Member

@jburel : will splitting the tests into subdirectories (or adding a @pytest.mark) help?

@jburel
Copy link
Member

jburel commented Feb 13, 2018

@joshmoore that was my next step to see what can be done at the tests level

@joshmoore joshmoore mentioned this pull request Feb 14, 2018
3 tasks
Previously, this repository was running both the "app"
and the "scripts" stages in order to modify the web &
the server containers, respectively. Attempts to have
both concurrently running proved difficult. Instead,
`.omero/docker app` now provides an `app-srv` hook so
that this repository can consider itself "just" an app.
@joshmoore
Copy link
Member

This looks like it's working. One test still failing but I think that's for @will-moore :


django_client = <django.test.client.Client object at 0x6e66310>
request_url = '/figure/list_web_figures/', data = None, status_code = 200
csrf = False

    def get_json(django_client, request_url, data=None, status_code=200,
                 csrf=False):
        """
        Performs a GET request and returns the JSON response as a dict.
    
        :param django_client:   Django test Client
        :param request_url:     The url to request
        :param data:            A dictionary of data, used to build a query string
        :param status_code:     Verify that the response has this status
        :param csrf:            If true, add csrf token to query string
    
        """
        rsp = get(django_client, request_url, data, status_code, csrf)
>       assert rsp.get('Content-Type') == 'application/json'
E       AssertionError

/opt/omero/web/OMERO.web/lib/python/omeroweb/testlib/__init__.py:362: AssertionError
------------------------------ Captured log setup ------------------------------
views.py                   104 INFO     INIT '455'
settings.py                885 INFO     Processing custom settings for module omeroweb.api.api_settings
__init__.py               2209 INFO     created connection (uuid=c52a8abf-68e3-4362-a20a-e00789e895f1)
connector.py               229 INFO     Client version: '['5', '4', '3']'; Server version: '['5', '4', '3']'
__init__.py               2209 INFO     created connection (uuid=64a0d3c6-5c72-4381-a5e9-9702e201f98c)
upgrade_check.py           148 INFO     no update needed
__init__.py               2209 INFO     created connection (uuid=53a44b34-cb35-4ad5-8631-fdf97de12c99)
connector.py               229 INFO     Client version: '['5', '4', '3']'; Server version: '['5', '4', '3']'
__init__.py               2209 INFO     created connection (uuid=a09ce5b0-f17d-4ac3-92c6-7297b69e70b8)
upgrade_check.py           148 INFO     no update needed
------------------------------ Captured log call -------------------------------
__init__.py               2209 INFO     created connection (uuid=854bf328-dbf0-4170-a9c6-59545f969836)
connector.py               229 INFO     Client version: '['5', '4', '3']'; Server version: '['5', '4', '3']'
__init__.py               2209 INFO     created connection (uuid=a320847d-fa01-469b-ba66-1d1d2aaea9b9)
upgrade_check.py           148 INFO     no update needed
__init__.py               2209 INFO     created connection (uuid=a320847d-fa01-469b-ba66-1d1d2aaea9b9)
---------------------------- Captured log teardown -----------------------------
__init__.py               2209 INFO     created connection (uuid=64a0d3c6-5c72-4381-a5e9-9702e201f98c)
__init__.py               1922 INFO     closed connecion (uuid=64a0d3c6-5c72-4381-a5e9-9702e201f98c)
__init__.py               2209 INFO     created connection (uuid=a09ce5b0-f17d-4ac3-92c6-7297b69e70b8)
__init__.py               1922 INFO     closed connecion (uuid=a09ce5b0-f17d-4ac3-92c6-7297b69e70b8)
__init__.py               2209 INFO     created connection (uuid=a320847d-fa01-469b-ba66-1d1d2aaea9b9)
__init__.py               1922 INFO     closed connecion (uuid=a320847d-fa01-469b-ba66-1d1d2aaea9b9)
===================== 1 failed, 4 passed in 27.40 seconds ======================

@jburel jburel mentioned this pull request Mar 3, 2018
@jburel
Copy link
Member

jburel commented Mar 3, 2018

Travis is now green. Suggested merging workflow

@jburel jburel merged commit f56ccb7 into ome:master Mar 4, 2018
@jburel jburel added this to the 3.2.1 milestone Apr 6, 2018
@jburel jburel modified the milestones: 3.2.1, 4.0.0 May 22, 2018
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.

3 participants