Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cms/djangoapps/contentstore/views/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ def create_template_dict(name, cat, boilerplate_name=None, is_common=False):
"Advanced component %s does not exist. It will not be added to the Studio new component menu.",
category
)
pass
else:
log.error(
"Improper format for course advanced keys! %s",
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/views/xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def xblock_resource(request, block_type, uri): # pylint: disable=unused-argumen
except IOError:
log.info('Failed to load xblock resource', exc_info=True)
raise Http404
except Exception: # pylint: disable-msg=broad-except
except Exception: # pylint: disable=broad-except
log.error('Failed to load xblock resource', exc_info=True)
raise Http404

Expand Down
Empty file added common/__init__.py
Empty file.
8 changes: 0 additions & 8 deletions common/lib/capa/capa/inputtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,6 @@ def get_attributes(cls):
]

def _extra_context(self):
"""
"""
context = {
'setup_script': '{static_url}js/capa/schematicinput.js'.format(
static_url=self.capa_system.STATIC_URL),
Expand Down Expand Up @@ -1410,8 +1408,6 @@ def get_attributes(cls):
Attribute('missing', None)]

def _extra_context(self):
"""
"""
context = {
'applet_loader': '{static_url}js/capa/editamolecule.js'.format(
static_url=self.capa_system.STATIC_URL),
Expand Down Expand Up @@ -1446,8 +1442,6 @@ def get_attributes(cls):
]

def _extra_context(self):
"""
"""
context = {
'applet_loader': '{static_url}js/capa/design-protein-2d.js'.format(
static_url=self.capa_system.STATIC_URL),
Expand Down Expand Up @@ -1482,8 +1476,6 @@ def get_attributes(cls):
]

def _extra_context(self):
"""
"""
context = {
'applet_loader': '{static_url}js/capa/edit-a-gene.js'.format(
static_url=self.capa_system.STATIC_URL),
Expand Down
3 changes: 1 addition & 2 deletions common/lib/capa/capa/tests/test_html_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def test_blank_problem(self):

# Render the HTML
etree.XML(problem.get_html())
# expect that we made it here without blowing up
self.assertTrue(True)
# TODO: This test should inspect the rendered html and assert one or more things about it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would somebody have added this line? It's truly doing nothing, right? Is the test even doing anything?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anything test anything!?

But yeah, it reminds me of something I saw recently (paraphrased):

self.assertIsNotNone(result)
self.assertIsNotNone(result.data)
self.assertEquals('ok', result.data.message)

It's like, just remove the first 2 checks and if it blows up, GOOD! That's what we want to know!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really doesn't test much though. It would be better to like, instantiate the XML as further problems do (rendered_html = etree.XML(problem.get_html())) and then actually assert something about the rendered_html itself.

I'm fine if you don't want to do that here, but if you don't want to do that, please add a TODO eg TODO: This test should inspect the rendered html and assert one or more things about it

def test_include_html(self):
# Create a test file to include
Expand Down
39 changes: 17 additions & 22 deletions common/lib/capa/capa/tests/test_responsetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@
from capa.responsetypes import LoncapaProblemError, \
StudentInputError, ResponseError
from capa.correctmap import CorrectMap
from capa.tests.response_xml_factory import (
AnnotationResponseXMLFactory,
ChoiceResponseXMLFactory,
CodeResponseXMLFactory,
ChoiceTextResponseXMLFactory,
CustomResponseXMLFactory,
FormulaResponseXMLFactory,
ImageResponseXMLFactory,
JavascriptResponseXMLFactory,
MultipleChoiceResponseXMLFactory,
NumericalResponseXMLFactory,
OptionResponseXMLFactory,
SchematicResponseXMLFactory,
StringResponseXMLFactory,
SymbolicResponseXMLFactory,
TrueFalseResponseXMLFactory,
)
from capa.util import convert_files_to_filenames
from capa.util import compare_with_tolerance
from capa.xqueue_interface import dateformat
Expand Down Expand Up @@ -77,7 +94,6 @@ def _get_random_number_result(self, seed_value):


class MultiChoiceResponseTest(ResponseTest):
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
xml_factory_class = MultipleChoiceResponseXMLFactory

def test_multiple_choice_grade(self):
Expand All @@ -99,7 +115,6 @@ def test_named_multiple_choice_grade(self):


class TrueFalseResponseTest(ResponseTest):
from capa.tests.response_xml_factory import TrueFalseResponseXMLFactory
xml_factory_class = TrueFalseResponseXMLFactory

def test_true_false_grade(self):
Expand Down Expand Up @@ -139,7 +154,6 @@ def test_named_true_false_grade(self):


class ImageResponseTest(ResponseTest):
from capa.tests.response_xml_factory import ImageResponseXMLFactory
xml_factory_class = ImageResponseXMLFactory

def test_rectangle_grade(self):
Expand Down Expand Up @@ -203,7 +217,6 @@ def test_show_answer(self):


class SymbolicResponseTest(ResponseTest):
from capa.tests.response_xml_factory import SymbolicResponseXMLFactory
xml_factory_class = SymbolicResponseXMLFactory

def test_grade_single_input_correct(self):
Expand Down Expand Up @@ -321,7 +334,6 @@ def _assert_symbolic_grade(


class OptionResponseTest(ResponseTest):
from capa.tests.response_xml_factory import OptionResponseXMLFactory
xml_factory_class = OptionResponseXMLFactory

def test_grade(self):
Expand Down Expand Up @@ -372,7 +384,6 @@ class FormulaResponseTest(ResponseTest):
"""
Test the FormulaResponse class
"""
from capa.tests.response_xml_factory import FormulaResponseXMLFactory
xml_factory_class = FormulaResponseXMLFactory

def test_grade(self):
Expand Down Expand Up @@ -521,7 +532,6 @@ def test_validate_answer(self):


class StringResponseTest(ResponseTest):
from capa.tests.response_xml_factory import StringResponseXMLFactory
xml_factory_class = StringResponseXMLFactory

def test_backward_compatibility_for_multiple_answers(self):
Expand Down Expand Up @@ -871,7 +881,6 @@ def gimme_a_random_hint(answer_ids, student_answers, new_cmap, old_cmap):


class CodeResponseTest(ResponseTest):
from capa.tests.response_xml_factory import CodeResponseXMLFactory
xml_factory_class = CodeResponseXMLFactory

def setUp(self):
Expand Down Expand Up @@ -1063,7 +1072,6 @@ def test_parse_score_msg_of_responder(self):


class ChoiceResponseTest(ResponseTest):
from capa.tests.response_xml_factory import ChoiceResponseXMLFactory
xml_factory_class = ChoiceResponseXMLFactory

def test_radio_group_grade(self):
Expand Down Expand Up @@ -1106,7 +1114,6 @@ def test_grade_with_no_checkbox_selected(self):


class JavascriptResponseTest(ResponseTest):
from capa.tests.response_xml_factory import JavascriptResponseXMLFactory
xml_factory_class = JavascriptResponseXMLFactory

def test_grade(self):
Expand Down Expand Up @@ -1147,7 +1154,6 @@ def test_cant_execute_javascript(self):


class NumericalResponseTest(ResponseTest):
from capa.tests.response_xml_factory import NumericalResponseXMLFactory
xml_factory_class = NumericalResponseXMLFactory

# We blend the line between integration (using evaluator) and exclusively
Expand Down Expand Up @@ -1372,7 +1378,6 @@ def test_validate_answer(self):


class CustomResponseTest(ResponseTest):
from capa.tests.response_xml_factory import CustomResponseXMLFactory
xml_factory_class = CustomResponseXMLFactory

def test_inline_code(self):
Expand Down Expand Up @@ -1924,7 +1929,6 @@ class SchematicResponseTest(ResponseTest):
"""
Class containing setup and tests for Schematic responsetype.
"""
from capa.tests.response_xml_factory import SchematicResponseXMLFactory
xml_factory_class = SchematicResponseXMLFactory

def test_grade(self):
Expand Down Expand Up @@ -1975,7 +1979,6 @@ def test_script_exception(self):


class AnnotationResponseTest(ResponseTest):
from capa.tests.response_xml_factory import AnnotationResponseXMLFactory
xml_factory_class = AnnotationResponseXMLFactory

def test_grade(self):
Expand Down Expand Up @@ -2017,7 +2020,6 @@ class ChoiceTextResponseTest(ResponseTest):
Class containing setup and tests for ChoiceText responsetype.
"""

from response_xml_factory import ChoiceTextResponseXMLFactory
xml_factory_class = ChoiceTextResponseXMLFactory

# `TEST_INPUTS` is a dictionary mapping from
Expand Down Expand Up @@ -2188,13 +2190,6 @@ def test_invalid_xml(self):
with self.assertRaises(Exception):
self.build_problem(type="invalidtextgroup")

def test_valid_xml(self):
"""
Test that `build_problem` builds valid xml
"""
self.build_problem()
self.assertTrue(True)

def test_unchecked_input_not_validated(self):
"""
Test that a student can have a non numeric answer in an unselected
Expand Down
2 changes: 1 addition & 1 deletion common/lib/xmodule/xmodule/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ def __init__(self, msg, service):
In addition to a msg, provide the name of the service.
"""
self.service = service
return super(HeartbeatFailure, self).__init__(msg)
super(HeartbeatFailure, self).__init__(msg)
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TestMixedModuleStore(CourseComparisonTest):
ASSET_COLLECTION = 'assetstore'
FS_ROOT = DATA_DIR
DEFAULT_CLASS = 'xmodule.raw_module.RawDescriptor'
RENDER_TEMPLATE = lambda t_n, d, ctx = None, nsp = 'main': ''
RENDER_TEMPLATE = lambda t_n, d, ctx=None, nsp='main': ''

MONGO_COURSEID = 'MITx/999/2013_Spring'
XML_COURSEID1 = 'edX/toy/2012_Fall'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
ASSET_COLLECTION = 'assetstore'
FS_ROOT = DATA_DIR # TODO (vshnayder): will need a real fs_root for testing load_item
DEFAULT_CLASS = 'xmodule.raw_module.RawDescriptor'
RENDER_TEMPLATE = lambda t_n, d, ctx = None, nsp = 'main': ''
RENDER_TEMPLATE = lambda t_n, d, ctx=None, nsp='main': ''


class ReferenceTestXBlock(XBlock, XModuleMixin):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ModuleStoreNoSettings(unittest.TestCase):
COLLECTION = 'modulestore'
FS_ROOT = DATA_DIR
DEFAULT_CLASS = 'xmodule.modulestore.tests.test_xml_importer.StubXBlock'
RENDER_TEMPLATE = lambda t_n, d, ctx = None, nsp = 'main': ''
RENDER_TEMPLATE = lambda t_n, d, ctx=None, nsp='main': ''

modulestore_options = {
'default_class': DEFAULT_CLASS,
Expand Down
2 changes: 1 addition & 1 deletion common/lib/xmodule/xmodule/modulestore/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def make_course_key(self, org, course, run):
"""
return CourseLocator(org, course, run, deprecated=True)

def get_courses(self, depth=0, **kwargs):
def get_courses(self, **kwargs):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we certain that nothing relies on depth as a positional argument?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My extensive grepping reveals no matches.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this hard to believe at first, but looking at the function signature for other definitions of get_courses, (self, **kwargs) seems to actually match what we already have elsewhere.

"""
Returns a list of course descriptors. If there were errors on loading,
some of these may be ErrorDescriptors instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,12 @@ def get_notifications(self, course_id, grader_id):
return result


"""
This is a mock peer grading service that can be used for unit tests
without making actual service calls to the grading controller
"""


class MockPeerGradingService(object):
"""
This is a mock peer grading service that can be used for unit tests
without making actual service calls to the grading controller
"""

def get_next_submission(self, problem_location, grader_id):
return {
'success': True,
Expand Down
8 changes: 1 addition & 7 deletions common/lib/xmodule/xmodule/tabs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
"""
Implement CourseTab
"""
# pylint: disable=incomplete-protocol
# Note: pylint complains that we do not implement __delitem__ and __len__, although we implement __setitem__
# and __getitem__. However, the former two do not apply to the CourseTab class so we do not implement them.
# The reason we implement the latter two is to enable callers to continue to use the CourseTab object with
# dict-type accessors.

from abc import ABCMeta, abstractmethod
from xblock.fields import List

Expand All @@ -15,7 +9,7 @@
_ = lambda text: text


class CourseTab(object): # pylint: disable=incomplete-protocol
class CourseTab(object):
"""
The Course Tab class is a data abstraction for all tabs (i.e., course navigation links) within a course.
It is an abstract class - to be inherited by various tab types.
Expand Down
2 changes: 1 addition & 1 deletion common/lib/xmodule/xmodule/tests/test_error_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class TestErrorModuleConstruction(unittest.TestCase):
"""
Test that error module construction happens correctly
"""

def setUp(self):
# pylint: disable=abstract-class-instantiated
super(TestErrorModuleConstruction, self).setUp()
field_data = Mock(spec=FieldData)
self.descriptor = BrokenDescriptor(
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/bulk_email/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
log = logging.getLogger(__name__)


class CourseEmailTemplateForm(forms.ModelForm): # pylint: disable=incomplete-protocol
class CourseEmailTemplateForm(forms.ModelForm):
"""Form providing validation of CourseEmail templates."""

name = forms.CharField(required=False)
Expand Down Expand Up @@ -73,7 +73,7 @@ def clean_name(self):
return name


class CourseAuthorizationAdminForm(forms.ModelForm): # pylint: disable=incomplete-protocol
class CourseAuthorizationAdminForm(forms.ModelForm):
"""Input form for email enabling, allowing us to verify data."""

class Meta: # pylint: disable=missing-docstring
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/bulk_email/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
)


def _get_recipient_queryset(user_id, to_option, course_id, course_location):
def _get_recipient_queryset(user_id, to_option, course_id):
"""
Returns a query set of email recipients corresponding to the requested to_option category.

Expand Down Expand Up @@ -230,7 +230,7 @@ def _create_send_email_subtask(to_list, initial_subtask_status):
)
return new_subtask

recipient_qset = _get_recipient_queryset(user_id, to_option, course_id, course.location)
recipient_qset = _get_recipient_queryset(user_id, to_option, course_id)
recipient_fields = ['profile__name', 'email']

log.info(u"Task %s: Preparing to queue subtasks for sending emails for course %s, email %s, to_option %s",
Expand Down
20 changes: 10 additions & 10 deletions lms/djangoapps/certificates/models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
from django.contrib.auth.models import User
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.conf import settings
from datetime import datetime
from model_utils import Choices
from xmodule_django.models import CourseKeyField, NoneToEmptyManager
from util.milestones_helpers import fulfill_course_milestone

"""
Certificates are created for a student and an offering of a course.

Expand Down Expand Up @@ -55,6 +45,16 @@
unless he has allow_certificate set to False.
"""

from django.contrib.auth.models import User
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.conf import settings
from datetime import datetime
from model_utils import Choices
from xmodule_django.models import CourseKeyField, NoneToEmptyManager
from util.milestones_helpers import fulfill_course_milestone


class CertificateStatuses(object):
deleted = 'deleted'
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/circuit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def circuit_line(circuit):
return xml.etree.ElementTree.tostring(circuit_line)


def edit_circuit(request, circuit):
def edit_circuit(_request, circuit):
try:
sc = ServerCircuit.objects.get(name=circuit)
except:
Expand Down
Loading