APS-4ID-POLAR / polartools

Python package to read and process data from the APS Polar beamline.
https://polartools.readthedocs.io/en/latest/
Other
2 stars 2 forks source link

How to test `load_databroker`? #4

Closed gfabbris closed 3 years ago

gfabbris commented 3 years ago

It didn't work to use preparing a catalog to test polartools.load_databroker.

See: https://github.com/APS-4ID-POLAR/polartools/blob/71b523180f866ac2668e503ae740a716c12d5136/polartools/tests/test_polartools.py#L13

From Pete: Use subprocess? https://github.com/APS-4ID-POLAR/polartools/commit/71b523180f866ac2668e503ae740a716c12d5136#r45253936

prjemian commented 3 years ago

Also, are you using a test framework, such as pytest? Might be easier to use tools within a test framework for this sort of setup.

gfabbris commented 3 years ago

Yes, it is using pytest. The one thing I changed (from apstools) was how to call pytest in the CI (below). But I think this is not the issue here.

in polartools:

   - name: Run tests with pytest
      run: |
        source $CONDA/bin/activate $ENV_NAME
        pytest
      env:
        PY_VER: ${{ matrix.python-version }}
        ENV_NAME: anaconda-test-env-py-${{ matrix.python-version }}

In apstools:

  - name: Run tests with pytest
      run: |
        source $CONDA/bin/activate $ENV_NAME
        pytest -vvv ./tests ./apstools/beamtime/tests
      env:
        PY_VER: ${{ matrix.python-version }}
        ENV_NAME: anaconda-test-env-py-${{ matrix.python-version }}
prjemian commented 3 years ago

Can you databroker-unpack inplace {path} test_data just before the source $CONDA/bin/activate $ENV_NAME line and pick a path within the test environment directory to use? Or /tmp/test_data, for example?

gfabbris commented 3 years ago

Good idea. This worked, but I had to run the databroker-unpackafter sourcing the environment, otherwise it can't find it.