From 37bf55e02363f60592384d6a16e80687d506a8d2 Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Fri, 23 Feb 2024 09:17:04 -0400 Subject: [PATCH] fix: address testing errors --- .../models/settings/tests/test_settings.py | 5 ++++- .../api/processors/team_partition_groups.py | 2 +- .../api/tests/test_outlines.py | 19 ++++++++++++++----- .../course_groups/team_partition_scheme.py | 3 ++- openedx/core/lib/teams_config.py | 1 - 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/cms/djangoapps/models/settings/tests/test_settings.py b/cms/djangoapps/models/settings/tests/test_settings.py index b8cbbd60261..474034a2a16 100644 --- a/cms/djangoapps/models/settings/tests/test_settings.py +++ b/cms/djangoapps/models/settings/tests/test_settings.py @@ -440,7 +440,10 @@ class TeamsConfigurationTests(unittest.TestCase): (config_block_no_global_max_team_size, set()), (config_block_course_max_team_size, {'max_team_size cannot be greater than 500'}), (config_block_teamset_max_team_size, {'max_team_size cannot be greater than 500'}), - (config_block_invalid_dynamic_partition_ids, {'dynamic_user_partition_id must be greater or equal than 51 and less than 100.'}) + ( + config_block_invalid_dynamic_partition_ids, + {'dynamic_user_partition_id must be greater or equal than 51 and less than 100.'} + ) ) @ddt.unpack def test_team_settings(self, config_block, error_message): diff --git a/openedx/core/djangoapps/content/learning_sequences/api/processors/team_partition_groups.py b/openedx/core/djangoapps/content/learning_sequences/api/processors/team_partition_groups.py index 9e332fa9311..8a4fbf43325 100644 --- a/openedx/core/djangoapps/content/learning_sequences/api/processors/team_partition_groups.py +++ b/openedx/core/djangoapps/content/learning_sequences/api/processors/team_partition_groups.py @@ -3,7 +3,7 @@ """ import logging from datetime import datetime -from typing import Dict, List +from typing import Dict from opaque_keys.edx.keys import CourseKey diff --git a/openedx/core/djangoapps/content/learning_sequences/api/tests/test_outlines.py b/openedx/core/djangoapps/content/learning_sequences/api/tests/test_outlines.py index d1caed05527..5612f385bfb 100644 --- a/openedx/core/djangoapps/content/learning_sequences/api/tests/test_outlines.py +++ b/openedx/core/djangoapps/content/learning_sequences/api/tests/test_outlines.py @@ -16,7 +16,10 @@ from opaque_keys.edx.locator import LibraryLocator import attr import ddt -from openedx.core.djangoapps.content.learning_sequences.api.processors.team_partition_groups import TeamPartitionGroupsOutlineProcessor +from lms.djangoapps.teams.tests.factories import CourseTeamFactory +from openedx.core.djangoapps.content.learning_sequences.api.processors.team_partition_groups import ( + TeamPartitionGroupsOutlineProcessor, +) from openedx.core.djangolib.testing.utils import skip_unless_lms import pytest @@ -2032,7 +2035,7 @@ def setUpTestData(cls): groups. - A student enrolled in the course and added to one of the teams. """ - from lms.djangoapps.teams.tests.factories import CourseTeamFactory, CourseTeamMembershipFactory + super().setUpTestData() cls.visibility = VisibilityData( hide_from_toc=False, visible_to_staff_only=False @@ -2119,7 +2122,8 @@ def test_load_data_in_partition_processor(self, team_sets_mock, team_configurati @patch("openedx.core.djangoapps.course_groups.partition_generator.get_team_sets") def test_user_not_excluded_by_partition_group(self, team_sets_mock, team_configuration_service_mock): """ - Test that the team partition groups processor correctly determines if a user is excluded by the partition groups. + Test that the team partition groups processor correctly determines if a user is excluded by the partition + groups. Expected result: - The user should not be excluded by the partition groups meaning the method should return False. @@ -2136,14 +2140,18 @@ def test_user_not_excluded_by_partition_group(self, team_sets_mock, team_configu } team_partition_groups_processor.load_data(self.outline) - assert not team_partition_groups_processor._is_user_excluded_by_partition_group(sequence_partition_groups) + # pylint: disable=protected-access + assert not team_partition_groups_processor._is_user_excluded_by_partition_group( + sequence_partition_groups + ) assert not team_partition_groups_processor._is_user_excluded_by_partition_group([]) @patch("openedx.core.djangoapps.course_groups.team_partition_scheme.TeamsConfigurationService") @patch("openedx.core.djangoapps.course_groups.partition_generator.get_team_sets") def test_user_excluded_by_partition_group(self, team_sets_mock, team_configuration_service_mock): """ - Test that the team partition groups processor correctly determines if a user is excluded by the partition groups. + Test that the team partition groups processor correctly determines if a user is excluded by the partition + groups. Expected result: - The user should not be excluded by the partition groups meaning the method should return False. @@ -2159,6 +2167,7 @@ def test_user_excluded_by_partition_group(self, team_sets_mock, team_configurati } team_partition_groups_processor.load_data(self.outline) + # pylint: disable=protected-access assert team_partition_groups_processor._is_user_excluded_by_partition_group(sequence_partition_groups) @patch("openedx.core.djangoapps.course_groups.team_partition_scheme.TeamsConfigurationService") diff --git a/openedx/core/djangoapps/course_groups/team_partition_scheme.py b/openedx/core/djangoapps/course_groups/team_partition_scheme.py index 43456aeda10..a71a9ff4daa 100644 --- a/openedx/core/djangoapps/course_groups/team_partition_scheme.py +++ b/openedx/core/djangoapps/course_groups/team_partition_scheme.py @@ -19,7 +19,8 @@ class TeamUserPartition(UserPartition): - """Extends UserPartition to support dynamic gcreate_team_set_partition_with_course_idroups pulled from the current course teams. + """Extends UserPartition to support dynamic gcreate_team_set_partition_with_course_idroups pulled from the current + course teams. Class attributes: team_sets_mapping (dict): A mapping of partition IDs to team-set IDs. diff --git a/openedx/core/lib/teams_config.py b/openedx/core/lib/teams_config.py index 8f9dcef4ba9..bcfbe6b86be 100644 --- a/openedx/core/lib/teams_config.py +++ b/openedx/core/lib/teams_config.py @@ -8,7 +8,6 @@ from django.utils.functional import cached_property -from openedx.core.djangoapps.course_groups.flags import CONTENT_GROUPS_FOR_TEAMS # "Arbitrarily large" but still limited MANAGED_TEAM_MAX_TEAM_SIZE = 200