Skip to content

Commit

Permalink
perf: plugin compatible with nutmeg (#216)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: drop django22 and added python 3.10

* feat: make it compatible with nutmeg

* perf: update requirements

* docs: update readme

* feat: drop django22 and added python 3.10

* ci: add python publish workflow and drop circleci

Co-authored-by: Maria Fernanda Magallanes Zubillaga <[email protected]>
Co-authored-by: Juan David Buitrago <[email protected]>
  • Loading branch information
3 people committed Oct 7, 2022
1 parent f3b8e6a commit 22f60b5
Show file tree
Hide file tree
Showing 17 changed files with 412 additions and 367 deletions.
120 changes: 0 additions & 120 deletions .circleci/config.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Publish Python 🐍 distributions 📦 to PyPI

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: |
python -m build --sdist --wheel --outdir dist/ .
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
strategy:
max-parallel: 2
matrix:
python-version: ["3.8"]
django: ["22","32"]
python-version: ["3.8", "3.10"]
django: ["32"]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ python-test: clean ## Run tests
$(TOX) coverage report --fail-under=70

python-quality-test:
$(TOX) pylint ./eox_core
$(TOX) pycodestyle ./eox_core
$(TOX) pylint ./eox_core
$(TOX) isort --check-only --diff ./eox_core

run-tests: python-test python-quality-test
Expand Down
41 changes: 27 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,23 @@ Installation on Open edX Devstack
Compatibility Notes
--------------------

+-------------------+----------+
| Open edX Release | Version |
+===================+==========+
| Ironwood | < 3.0 |
+-------------------+----------+
| Juniper | >= 3.0 |
+-------------------+----------+
| Koa | >= 4.9 |
+-------------------+----------+
| Lilac | >= 4.9 |
+-------------------+----------+
| Maple | >= 6.0 |
+-------------------+----------+
+-------------------+-----------------+
| Open edX Release | Version |
+===================+=================+
| Ironwood | < 3.0 |
+-------------------+-----------------+
| Juniper | >= 3.0 < 5.0 |
+-------------------+-----------------+
| Koa | >= 4.9 < 6.0 |
+-------------------+-----------------+
| Lilac | >= 4.9 < 6.0 |
+-------------------+-----------------+
| Maple | >= 6.0 |
+-------------------+-----------------+
| Nutmeg | >= 7.0 |
+-------------------+-----------------+

**NOTE**: The Maple version does not support Django 2.2 but it does support Django 3.2 as of eox-core 7.0.

The following changes to the plugin settings are necessary. If the release you are looking for is
not listed, then the accumulation of changes from previous releases is enough.
Expand Down Expand Up @@ -132,6 +136,14 @@ not listed, then the accumulation of changes from previous releases is enough.
**Maple**

.. code-block:: yaml
EOX_CORE_USERS_BACKEND: "eox_core.edxapp_wrapper.backends.users_m_v1"
EOX_CORE_PRE_ENROLLMENT_BACKEND: "eox_core.edxapp_wrapper.backends.pre_enrollment_l_v1"
EOX_CORE_ENROLLMENT_BACKEND: "eox_core.edxapp_wrapper.backends.enrollment_l_v1"
**Nutmeg**

.. code-block:: yaml
EOX_CORE_USERS_BACKEND: "eox_core.edxapp_wrapper.backends.users_m_v1"
Expand All @@ -140,7 +152,8 @@ not listed, then the accumulation of changes from previous releases is enough.
These settings can be changed in ``eox_core/settings/common.py`` or, for example, in ansible configurations.

**NOTE**: the current ``common.py`` works with Open edX juniper version.
**NOTE**: the current ``common.py`` works with Open edX Nutmeg version.


Dependency Management
=====================
Expand Down
104 changes: 104 additions & 0 deletions eox_core/edxapp_wrapper/backends/users_m_v1_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
"""
Test backend to get CourseEnrollment Model.
"""

from unittest.mock import Mock

from django.contrib.auth.models import Permission

USERNAME_MAX_LENGTH = 30


def get_edxapp_user(**kwargs):
"""
Return a fake user
"""
return Mock()


def create_edxapp_user(*args, **kwargs):
"""
Return a fake user and a list of errors
"""
return Mock(), []


def get_user_read_only_serializer():
"""
Return a fake user read only serializer
"""
try:
from openedx.core.djangoapps.user_api.accounts.serializers import \
UserReadOnlySerializer # pylint: disable=import-outside-toplevel
except ImportError:
UserReadOnlySerializer = object
return UserReadOnlySerializer


def check_edxapp_account_conflicts(email, username):
"""
Get an executes the check_account_exists for tests
"""
try:
from openedx.core.djangoapps.user_api.accounts.api import \
check_account_exists # pylint: disable=import-outside-toplevel
except ImportError:
def check_account_exists(email=None, username=None):
"""
Fake definition for check_account_exists edxapp function
"""
return email and username
return check_account_exists(email=email, username=username)


def get_course_enrollment():
"""
Get Test CourseEnrollment model.
We return any django model that already exists so that
django-filters is happy and no migrations are created.
"""
return Permission


def get_course_team_user(*args, **kwargs):
"""
Return a fake course team user
"""
return Mock()


def get_user_signup_source():
"""
Get test UserSignupSource model
"""
try:
from common.djangoapps.student.models import UserSignupSource # pylint: disable=import-outside-toplevel
except ImportError:
UserSignupSource = object
return UserSignupSource


def get_user_profile():
""" Gets the UserProfile model """
try:
from common.djangoapps.student.models import UserProfile # pylint: disable=import-outside-toplevel
except ImportError:
UserProfile = object
return UserProfile


def generate_password(*args, **kwargs):
""" Generates a password """
return "ThisShouldBeARandomPassword"


def get_user_attribute():
"""
Get test UserAttribute model
"""
try:
from common.djangoapps.student.models import UserAttribute # pylint: disable=import-outside-toplevel
except ImportError:
UserAttribute = object
return UserAttribute
2 changes: 1 addition & 1 deletion eox_core/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def plugin_settings(settings): # pylint: disable=function-redefined
Defines eox-core settings when app is used as a plugin to edx-platform.
See: https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/plugins/README.rst
"""
settings.EOX_CORE_USERS_BACKEND = "eox_core.edxapp_wrapper.backends.users_l_v1_test"
settings.EOX_CORE_USERS_BACKEND = "eox_core.edxapp_wrapper.backends.users_m_v1_test"
settings.EOX_CORE_ENROLLMENT_BACKEND = "eox_core.edxapp_wrapper.backends.enrollment_l_v1"
settings.EOX_CORE_PRE_ENROLLMENT_BACKEND = "eox_core.edxapp_wrapper.backends.pre_enrollment_l_v1"
settings.EOX_CORE_COURSEKEY_BACKEND = "eox_core.edxapp_wrapper.backends.coursekey_h_v1"
Expand Down
13 changes: 6 additions & 7 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ django-filter
django-oauth-toolkit
django-oauth2-provider
django-waffle
edx-api-doc-tools<1.6
edx-proctoring
edx-opaque-keys[django]
openedx-events==0.6.0
django<3.3
click<8.0.0

edx-api-doc-tools
edx-proctoring>=2.0.1
edx-opaque-keys[django]==2.3.0
openedx-events==0.8.1
django
click
Loading

0 comments on commit 22f60b5

Please sign in to comment.