appsembler / figures

Reporting and data retrieval app for Open edX
MIT License
44 stars 37 forks source link

Pytest is missing devsite .env file and default Open edX release #331

Closed johnbaldwin closed 2 years ago

johnbaldwin commented 3 years ago

Issue #1 pytest failes because devsite/devsite/.env does not exist

Running pytest fails with the following:

$ pytest
/home/jbaldwin/.pyenv/versions/3.5.10/envs/figpy35/lib/python3.5/site-packages/environ/environ.py:630: UserWarning: /home/jbaldwin/work/appsembler/ws/figures/devsite/devsite/.env doesn't exist - if you're not configuring your environment separately, create one.
  "environment separately, create one." % env_file)

Tox does work. Tox calling pytest works because tox defines environment variables that the devsite settings file expects. These enviroment var

The package used is here: https://github.com/joke2k/django-environ

It is unfortunate that the package seems to not be actively maintained. However, we use it only for Figures devsite and not in production.

Issue #2: There is not a default Open edX release defined. This can be seen if one creates an empty devsite/devsite/.env file.

The .env file loads environment variables that are then read in the devsite settings.py and test_settings.py files

There are options to fix this (here are just some):

  1. Improve the error message if .env is missing
  2. Add a default .env file with a default Open edX release
  3. For the test_settings.py, use a test.env file
  4. Remove use of django-environ and implement an alternate strategy for setting environment variables
  5. Dynamically create a .env file with default settings if one does not already exist

TODO: dig into the options and choose

  1. Quick fix for now
  2. Then long term solution
johnbaldwin commented 2 years ago

I believe I fixed this with https://github.com/appsembler/figures/pull/443 (it works on my computer ;))