Running Unit Tests in tutor


Needed pointers on approaches to running the edX unit test files (example) in tutor. (I specifically want to test the Discovery API unit tests.)

Based on my looking around, found two starting points:
edx-platform testing guide doc
running discovery tests with Devstack

Would any of the above documents be applicable for running the tests in tutor as well? Thanks.

I have never tried to run the discovery unit tests, so I wouldn’t know what to tell you. From my experience, unit tests in Open edX require weird tools and folder structure. Basically, tutor is not well suited for hacking on the master branch of Open edX repos, so I usually just stick with the devstack for running unit tests.

Thanks @regis

Basically, tutor is not well suited for hacking on the master branch of Open edX repos

the above was not the use case, however :slight_smile:

we just wanted to put logs (print statement) in the unit tests as some of the tests would provide us an easy way to understand the valid inputs to the Discovery’s APIs that are totally undocumented. I am assuming that your answer would not change for this use case as well :wink:

Oh, so you want to run unit tests in the named releases? This might just work. You will have to install the development requirements inside the docker container. Please post your findings here!

Here’s the finding…

  1. In ran tutor dev runserver discovery bash (container is pointing to local repo)

  2. I prepared the container to run the unit tests by running the below commands.

#pip install wheel
#pip install -U pytest`
#pip install --requirement requirements/test.txt

The last command worked mostly well, but encountered the below errors. I moved forward…

ERROR: django-haystack 2.5.0 has requirement Django<1.10, but you’ll have django 1.11.29 which is incompatible.

ERROR: drf-haystack 1.6.1 has requirement Django<1.11,>=1.8, but you’ll have django 1.11.29 which is incompatible.

  1. I finally attempted to run a test:
    #pytest course_discovery/apps/api/v1/tests/test_views/ --ds=course_discovery.settings.test_local

The run was not successful. I tried without luck to troubleshoot further. Here are the Detailed Error Logs

any pointers on further troubleshooting this? any apparent steps I am missing here? Thanks!

I have no idea, except that you should not install pytest manually with pip install -U pytest. Instead, you should simply install the requirements from test.txt.