-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
216 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
"""Constants for the FutureX Open edX Extensions app.""" | ||
CACHE_NAME_ALL_TENANTS_INFO = "all_tenants_info" | ||
CACHE_NAME_ALL_COURSE_ORG_FILTER_LIST = "all_course_org_filter_list" | ||
|
||
COURSE_STATUSES = { | ||
'active': 'active', | ||
'archived': 'archived', | ||
'upcoming': 'upcoming', | ||
"active": "active", | ||
"archived": "archived", | ||
"upcoming": "upcoming", | ||
} | ||
|
||
COURSE_STATUS_SELF_PREFIX = 'self_' | ||
COURSE_STATUS_SELF_PREFIX = "self_" | ||
|
||
TENANT_LIMITED_ADMIN_ROLES = ["org_course_creator_group"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Helper functions for FutureX Open edX Extensions.""" | ||
from __future__ import annotations | ||
|
||
from typing import List | ||
|
||
|
||
def get_first_not_empty_item(items: List, default=None) -> any: | ||
"""Return the first item in the list that is not empty.""" | ||
return next((item for item in items if item), default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test_utils/edx_platform_mocks/common/djangoapps/student/models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Tests for the helper functions in the helpers module.""" | ||
import pytest | ||
|
||
from futurex_openedx_extensions.helpers.helpers import get_first_not_empty_item | ||
|
||
|
||
@pytest.mark.parametrize("items, expected, error_message", [ | ||
([0, None, False, "", 3, "hello"], 3, "Test with a list containing truthy and falsy values"), | ||
([0, None, False, ""], None, "Test with a list containing only falsy values"), | ||
([1, "a", [1], {1: 1}], 1, "Test with a list containing only truthy values"), | ||
([], None, "Test with an empty list"), | ||
([0, [], {}, (), "non-empty"], "non-empty", "Test with a list containing mixed types"), | ||
([[], {}, (), 5], 5, "Test with a list containing different truthy types"), | ||
([None, "test"], "test", "Test with None as an element"), | ||
([[None, []], [], [1, 2, 3]], [None, []], "Test with nested lists"), | ||
(["first", 0, None, False, "", 3, "hello"], "first", "Test with first element truthy") | ||
]) | ||
def test_get_first_not_empty_item(items, expected, error_message): | ||
"""Verify that the get_first_not_empty_item function returns the first non-empty item in the list.""" | ||
assert get_first_not_empty_item(items) == expected, f"Failed: {error_message}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters