Skip to content
Snippets Groups Projects
Unverified Commit 875a06d2 authored by Awais Qureshi's avatar Awais Qureshi Committed by GitHub
Browse files

Merge pull request #26674 from edx/BOM-2373-course_action_state

Run Pyupgrade on course-action-state.
parents 013f7bfe 4ab536e5
Branches
Tags release-2021-03-05-09.07
No related merge requests found
......@@ -4,7 +4,6 @@ Model Managers for Course Actions
import traceback
import six
from django.db import models, transaction
......@@ -13,7 +12,7 @@ class CourseActionStateManager(models.Manager):
An abstract Model Manager class for Course Action State models.
This abstract class expects child classes to define the ACTION (string) field.
"""
class Meta(object):
class Meta:
"""Abstract manager class, with subclasses defining the ACTION (string) field."""
abstract = True
......@@ -90,7 +89,7 @@ class CourseActionUIStateManager(CourseActionStateManager):
# update any additional fields in kwargs
if kwargs:
for key, value in six.iteritems(kwargs):
for key, value in kwargs.items():
setattr(state_object, key, value)
state_object.save()
......@@ -109,7 +108,7 @@ class CourseRerunUIStateManager(CourseActionUIStateManager):
"""
ACTION = "rerun"
class State(object):
class State:
"""
An Enum class for maintaining the list of possible states for Reruns.
"""
......
# -*- coding: utf-8 -*-
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
......@@ -25,13 +23,13 @@ class Migration(migrations.Migration):
('should_display', models.BooleanField(default=False)),
('message', models.CharField(max_length=1000)),
('source_course_key', CourseKeyField(max_length=255, db_index=True)),
('display_name', models.CharField(default=u'', max_length=255, blank=True)),
('display_name', models.CharField(default='', max_length=255, blank=True)),
('created_user', models.ForeignKey(related_name='created_by_user+', on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True)),
('updated_user', models.ForeignKey(related_name='updated_by_user+', on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True)),
],
),
migrations.AlterUniqueTogether(
name='coursererunstate',
unique_together=set([('course_key', 'action')]),
unique_together={('course_key', 'action')},
),
]
......@@ -13,6 +13,7 @@ file and check it in at the same time as your model changes. To do that,
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.db import models
from opaque_keys.edx.django.models import CourseKeyField
from common.djangoapps.course_action_state.managers import CourseActionStateManager, CourseRerunUIStateManager
......@@ -22,7 +23,7 @@ class CourseActionState(models.Model):
For example: course copying (reruns), import, export, and validation.
"""
class Meta(object):
class Meta:
"""
For performance reasons, we disable "concrete inheritance", by making the Model base class abstract.
With the "abstract base class" inheritance model, tables are only created for derived models, not for
......@@ -78,7 +79,7 @@ class CourseActionUIState(CourseActionState):
"""
An abstract django model that is a sub-class of CourseActionState with additional fields related to UI.
"""
class Meta(object):
class Meta:
"""
See comment in CourseActionState on disabling "concrete inheritance".
"""
......@@ -104,7 +105,7 @@ class CourseRerunState(CourseActionUIState):
.. no_pii:
"""
class Meta(object):
class Meta:
"""
Set the (destination) course_key field to be unique for the rerun action
Although multiple reruns can be in progress simultaneously for a particular source course_key,
......@@ -117,7 +118,7 @@ class CourseRerunState(CourseActionUIState):
source_course_key = CourseKeyField(max_length=255, db_index=True)
# Display name for destination course
display_name = models.CharField(max_length=255, default=u"", blank=True)
display_name = models.CharField(max_length=255, default="", blank=True)
# MANAGERS
# Override the abstract class' manager with a Rerun-specific manager that inherits from the base class' manager.
......
......@@ -9,7 +9,6 @@ import pytest
from ddt import data, ddt
from django.test import TestCase
from opaque_keys.edx.locations import CourseLocator
from six.moves import range
from common.djangoapps.course_action_state.managers import CourseActionStateItemNotFoundError
from common.djangoapps.course_action_state.models import CourseRerunState
......@@ -23,7 +22,7 @@ class TestCourseActionStateManagerBase(TestCase):
Base class for testing Course Action State Managers.
"""
def setUp(self):
super(TestCourseActionStateManagerBase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.course_key = CourseLocator("test_org", "test_course_num", "test_run")
......@@ -118,8 +117,8 @@ class TestCourseActionUIStateManager(TestCourseActionStateManagerBase):
def assertCourseActionStatesEqual(self, expected, found):
"""Asserts that the set of course keys in the expected state equal those that are found"""
self.assertSetEqual(
set(course_action_state.course_key for course_action_state in expected),
set(course_action_state.course_key for course_action_state in found))
{course_action_state.course_key for course_action_state in expected},
{course_action_state.course_key for course_action_state in found})
@data(*COURSE_ACTION_STATES)
def test_find_all_for_display(self, action_class):
......
......@@ -5,7 +5,6 @@ Tests specific to the CourseRerunState Model and Manager.
from django.test import TestCase
from opaque_keys.edx.locations import CourseLocator
from six import text_type
from common.djangoapps.course_action_state.managers import CourseRerunUIStateManager
from common.djangoapps.course_action_state.models import CourseRerunState
......@@ -17,7 +16,7 @@ class TestCourseRerunStateManager(TestCase):
Test class for testing the CourseRerunUIStateManager.
"""
def setUp(self):
super(TestCourseRerunStateManager, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
super().setUp()
self.source_course_key = CourseLocator("source_org", "source_course_num", "source_run")
self.course_key = CourseLocator("test_org", "test_course_num", "test_run")
self.created_user = UserFactory()
......@@ -105,7 +104,7 @@ class TestCourseRerunStateManager(TestCase):
)
self.expected_rerun_state.pop('message')
rerun = self.verify_rerun_state()
assert text_type(exception) in rerun.message
assert str(exception) in rerun.message
# dismiss ui and verify
self.dismiss_ui_and_verify(rerun)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment