Setting up and running tests

I’m following the guidelines published here, however, this guide omits the “Getting Started” material. Thus far i’ve reasoned that the following is necessary on a native build of any version of open edx:

  1. launch the edxapp virtual environment using these commands
    sudo -H -u edxapp bash
    cd ~
    source edxapp_env
    source venvs/edxapp/bin/activate
    cd edx-platform
  2. install additional pip requirements using these commands
    pip install -r requirements/*.txt
    pip install pytest-json-report
    pip install pytest-cov
    pip install pyquery==1.4.0
    pip install nose==1.3.7

however, i still encounter three types of problems.
First, custom settings that i’ve added to lms/envs/ as well as lms/envs/ are not found by the testing programs, regardless of whether i use paver, pytest or
QUESTION: where else do i need to add my custom configuration settings?

Second, (and perhaps more urgently) all tests that i’ve attempted so far fail with the message, “pymongo.errors.OperationFailure: there are no users authenticated”.

QUESTION: how do i provide an authenticated user to mongo?

Third, when i try to test with the sqlite database it creates is missing all of my custom models. these are found and are currently running on the subject open edx instance, however, the code doesn’t see them.

QUESTION: Why doesn’t’s test functionality see my models?

Tests are generally supposed to be run using the test settings, they will not pick up changes to those files. What custom settings are you trying to change? If you are adding new tests or modifying existing ones and need to add settings to support them, then you can add the settings at lms/envs/ and cms/envs/ If you want to override the settings for the existing tests, then know that this will likely break a lot of tests and they will not work as expected.

How have you set up your Open edX environment? Are you using the Docker-based devstack? If not you should be using that.

How are these custom models added? Where are they added? How are they integrated with edx-platform?

hi kshitij and thanks for responding. responses:

  1. it is a native build that has been customized, not a devstack. its built using the ansible scripts that are provided by edx at github/edx/configuration/util/install/ my client has a substantial investment in the code base on which i’m working, so starting over with devstack/docker is not an option. but your response might distract from my question, so more importantly: are you aware of the existence of any technical dependencies that have evolved between the open edx tests and docker?

  2. models: i appreciate your response but i don’t want this question/thread to drift into the weeds. the models are added to installed_apps in lms/envs/ and lms/envs/; neither of which seems to be read by the open edx testing tools which, kshitij, is the nature of my question. to your response to my question 1: the testing tools do not seem to actually read the file lms/envs/ do you know why?

The idea wasn’t to start over from scratch certainly, merely that tests are often designed to run in a very specific environment that they control, so altering that is hard without deep knowledge of the tests and why the environment is being changed. A lot of settings are loaded from lms.envs.test but then modified by the tests themselves.

I don’t think the tests rely on Docker. I’ve personally often run them on sandbox server that aren’t running in Docker, but are deployed using Ansible.

However, the tests may expect the mongo db to be configured a particular way or present at a particular location that might not hold true for a customised deployment.

You can override the mongo test server settings here:

I think you might have a better luck downloading a compatible version of mongodb. Running it locally in a separate port and using that for tests.

I am unable to replicate the issues you mention, hence the additional questions :slight_smile:
When I add a new setting to lms/envs/ or modify an existing I am able to see it in tests.

Note, I am not pinged if you use my name in the forum, so it’s harder to follow. If you use @xitij2000 it will show up as a notification for me. I think the same should happen if you click on the reply button under my reply instead of a blue reply button at the bottom.