Skip to content
Snippets Groups Projects
Commit 272751c8 authored by Stu Young's avatar Stu Young Committed by Douglas Hall
Browse files

incr-300 (#20624)

* run python modernize

* run isort

* Fix imports
parent 6478d433
No related branches found
No related tags found
No related merge requests found
"""
Management command to update course_teams' search index.
"""
from __future__ import print_function, unicode_literals
from __future__ import absolute_import, print_function, unicode_literals
from textwrap import dedent
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.core.management import BaseCommand, CommandError
from six.moves import map
from lms.djangoapps.teams.models import CourseTeam
......@@ -62,7 +64,7 @@ class Command(BaseCommand):
if options['all']:
course_teams = CourseTeam.objects.all()
else:
course_teams = map(self._get_course_team, options['course_team_ids'])
course_teams = list(map(self._get_course_team, options['course_team_ids']))
for course_team in course_teams:
print('Indexing {}'.format(course_team.team_id))
......
......@@ -2,6 +2,8 @@
Tests for course_team reindex command
"""
from __future__ import absolute_import
import ddt
from django.core.management import CommandError, call_command
from mock import patch
......
"""Factories for testing the Teams API."""
from __future__ import absolute_import
from datetime import datetime
from uuid import uuid4
......
# -*- coding: utf-8 -*-
"""Tests for the teams API at the HTTP request level."""
from __future__ import absolute_import
import itertools
from contextlib import contextmanager
from datetime import datetime
......@@ -9,6 +11,9 @@ import pytz
from mock import Mock
from opaque_keys.edx.keys import CourseKey
from lms.djangoapps.teams import TEAM_DISCUSSION_CONTEXT
from lms.djangoapps.teams.models import CourseTeam, CourseTeamMembership
from lms.djangoapps.teams.tests.factories import CourseTeamFactory, CourseTeamMembershipFactory
from openedx.core.djangoapps.django_comment_common.signals import (
comment_created,
comment_deleted,
......@@ -20,9 +25,6 @@ from openedx.core.djangoapps.django_comment_common.signals import (
thread_edited,
thread_voted
)
from lms.djangoapps.teams import TEAM_DISCUSSION_CONTEXT
from lms.djangoapps.teams.models import CourseTeam, CourseTeamMembership
from lms.djangoapps.teams.tests.factories import CourseTeamFactory, CourseTeamMembershipFactory
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from util.testing import EventTestMixin
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
......@@ -179,7 +181,7 @@ class TeamSignalsTest(EventTestMixin, SharedModuleStoreTestCase):
@ddt.data(
*itertools.product(
SIGNALS.keys(),
list(SIGNALS.keys()),
(('user', True), ('moderator', False))
)
)
......@@ -202,7 +204,7 @@ class TeamSignalsTest(EventTestMixin, SharedModuleStoreTestCase):
signal = self.SIGNALS[signal_name]
signal.send(sender=None, user=self.user, post=self.mock_comment(user=self.moderator))
@ddt.data(*SIGNALS.keys())
@ddt.data(*list(SIGNALS.keys()))
def test_signals_course_context(self, signal_name):
"""Test that `last_activity_at` is not updated when activity takes
place in discussions outside of a team.
......
......@@ -2,6 +2,9 @@
"""
Tests for custom Teams Serializers.
"""
from __future__ import absolute_import
import six
from django.core.paginator import Paginator
from django.test.client import RequestFactory
......@@ -139,13 +142,13 @@ class BaseTopicSerializerTestCase(SerializerTestCase):
"""
self.course.teams_configuration['topics'] = []
topics = [
{u'name': u'Tøpic {}'.format(i), u'description': u'The bést topic! {}'.format(i), u'id': unicode(i)}
for i in xrange(num_topics)
{u'name': u'Tøpic {}'.format(i), u'description': u'The bést topic! {}'.format(i), u'id': six.text_type(i)}
for i in six.moves.range(num_topics)
]
for i in xrange(num_topics):
topic_id = unicode(i)
for i in six.moves.range(num_topics):
topic_id = six.text_type(i)
self.course.teams_configuration['topics'].append(topics[i])
for _ in xrange(teams_per_topic):
for _ in six.moves.range(teams_per_topic):
CourseTeamFactory.create(course_id=self.course.id, topic_id=topic_id)
return topics
......@@ -234,13 +237,13 @@ class BulkTeamCountTopicSerializerTestCase(BaseTopicSerializerTestCase):
"""
self.course.teams_configuration['topics'] = []
topics = [
{u'name': u'Tøpic {}'.format(i), u'description': u'The bést topic! {}'.format(i), u'id': unicode(i)}
for i in xrange(num_topics)
{u'name': u'Tøpic {}'.format(i), u'description': u'The bést topic! {}'.format(i), u'id': six.text_type(i)}
for i in six.moves.range(num_topics)
]
for i in xrange(num_topics):
topic_id = unicode(i)
for i in six.moves.range(num_topics):
topic_id = six.text_type(i)
self.course.teams_configuration['topics'].append(topics[i])
for _ in xrange(teams_per_topic):
for _ in six.moves.range(teams_per_topic):
CourseTeamFactory.create(course_id=self.course.id, topic_id=topic_id)
return topics
......
# -*- coding: utf-8 -*-
"""Tests for the teams API at the HTTP request level."""
from __future__ import absolute_import
import json
import unittest
from datetime import datetime
......@@ -8,13 +10,14 @@ import ddt
import pytz
from dateutil import parser
from django.conf import settings
from django.urls import reverse
from django.db.models.signals import post_save
from django.urls import reverse
from django.utils import translation
from elasticsearch.exceptions import ConnectionError
from mock import patch
from rest_framework.test import APIClient, APITestCase
from search.search_engine_base import SearchEngine
from six.moves import range
from common.test.utils import skip_signal
from courseware.tests.factories import StaffFactory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment