Commit 5d540360 by Martyn James Committed by Dino Cikatic

Fix pylint violation

parent ee90c5fe
...@@ -3,10 +3,10 @@ from __future__ import absolute_import ...@@ -3,10 +3,10 @@ from __future__ import absolute_import
import logging import logging
from django.conf import settings
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from search.search_engine_base import SearchEngine from search.search_engine_base import SearchEngine
from eventtracking import tracker
from . import ModuleStoreEnum from . import ModuleStoreEnum
from .exceptions import ItemNotFoundError from .exceptions import ItemNotFoundError
...@@ -139,7 +139,7 @@ class CoursewareSearchIndexer(object): ...@@ -139,7 +139,7 @@ class CoursewareSearchIndexer(object):
Add to courseware search index published section and children Add to courseware search index published section and children
""" """
indexed_count = cls.add_to_search_index(modulestore, location, delete, raise_on_error) indexed_count = cls.add_to_search_index(modulestore, location, delete, raise_on_error)
CoursewareSearchIndexer._track_index_request('edx.course.index.published', indexed_count, str(location)) cls._track_index_request('edx.course.index.published', indexed_count, str(location))
return indexed_count return indexed_count
@classmethod @classmethod
...@@ -148,7 +148,7 @@ class CoursewareSearchIndexer(object): ...@@ -148,7 +148,7 @@ class CoursewareSearchIndexer(object):
(Re)index all content within the given course (Re)index all content within the given course
""" """
indexed_count = cls.add_to_search_index(modulestore, course_key, delete=False, raise_on_error=True) indexed_count = cls.add_to_search_index(modulestore, course_key, delete=False, raise_on_error=True)
CoursewareSearchIndexer._track_index_request('edx.course.index.reindexed', indexed_count) cls._track_index_request('edx.course.index.reindexed', indexed_count)
return indexed_count return indexed_count
@staticmethod @staticmethod
...@@ -162,10 +162,6 @@ class CoursewareSearchIndexer(object): ...@@ -162,10 +162,6 @@ class CoursewareSearchIndexer(object):
None None
""" """
from eventtracking import tracker as track
tracker = track.get_tracker()
tracking_context = tracker.resolve_context() # pylint: disable=no-member
data = { data = {
"indexed_count": indexed_count, "indexed_count": indexed_count,
'category': 'courseware_index', 'category': 'courseware_index',
......
...@@ -12,6 +12,7 @@ import os ...@@ -12,6 +12,7 @@ import os
import pprint import pprint
import unittest import unittest
import inspect import inspect
import mock
from contextlib import contextmanager from contextlib import contextmanager
from lazy import lazy from lazy import lazy
...@@ -21,6 +22,7 @@ from path import path ...@@ -21,6 +22,7 @@ from path import path
from eventtracking import tracker from eventtracking import tracker
from eventtracking.django import DjangoTracker from eventtracking.django import DjangoTracker
from xblock.field_data import DictFieldData from xblock.field_data import DictFieldData
from xblock.fields import ScopeIds, Scope, Reference, ReferenceList, ReferenceValueDict from xblock.fields import ScopeIds, Scope, Reference, ReferenceList, ReferenceValueDict
...@@ -56,7 +58,8 @@ class TestModuleSystem(ModuleSystem): # pylint: disable=abstract-method ...@@ -56,7 +58,8 @@ class TestModuleSystem(ModuleSystem): # pylint: disable=abstract-method
""" """
ModuleSystem for testing ModuleSystem for testing
""" """
def __init__(self, **kwargs): @mock.patch('eventtracking.tracker.emit')
def __init__(self, mock_emit, **kwargs): # pylint: disable=unused-argument
id_manager = CourseLocationManager(kwargs['course_id']) id_manager = CourseLocationManager(kwargs['course_id'])
kwargs.setdefault('id_reader', id_manager) kwargs.setdefault('id_reader', id_manager)
kwargs.setdefault('id_generator', id_manager) kwargs.setdefault('id_generator', id_manager)
......
...@@ -42,6 +42,7 @@ define([ ...@@ -42,6 +42,7 @@ define([
logSearchItem: function(event) { logSearchItem: function(event) {
event.preventDefault(); event.preventDefault();
var self = this;
var target = this.model.id; var target = this.model.id;
var link = $(event.target).attr('href'); var link = $(event.target).attr('href');
var collection = this.model.collection; var collection = this.model.collection;
...@@ -54,8 +55,9 @@ define([ ...@@ -54,8 +55,9 @@ define([
"search_term": searchTerm, "search_term": searchTerm,
"result_position": (page * pageSize + index), "result_position": (page * pageSize + index),
"result_link": target "result_link": target
}).always(function() {
self.redirect(link);
}); });
this.redirect(link);
} }
}); });
......
...@@ -2,6 +2,7 @@ define([ ...@@ -2,6 +2,7 @@ define([
'jquery', 'jquery',
'sinon', 'sinon',
'backbone', 'backbone',
'logger',
'js/common_helpers/template_helpers', 'js/common_helpers/template_helpers',
'js/search/views/search_form', 'js/search/views/search_form',
'js/search/views/search_item_view', 'js/search/views/search_item_view',
...@@ -14,6 +15,7 @@ define([ ...@@ -14,6 +15,7 @@ define([
$, $,
Sinon, Sinon,
Backbone, Backbone,
Logger,
TemplateHelpers, TemplateHelpers,
SearchForm, SearchForm,
SearchItemView, SearchItemView,
...@@ -123,6 +125,7 @@ define([ ...@@ -123,6 +125,7 @@ define([
// Mock the redirect call // Mock the redirect call
spyOn(this.item, 'redirect').andCallFake( function() {} ); spyOn(this.item, 'redirect').andCallFake( function() {} );
spyOn(this.item, 'logSearchItem').andCallThrough(); spyOn(this.item, 'logSearchItem').andCallThrough();
spyOn(Logger, 'log').andReturn($.Deferred().resolve());
var link = this.item.$el.find('a'); var link = this.item.$el.find('a');
expect(link.length).toBe(1); expect(link.length).toBe(1);
link.trigger('click'); link.trigger('click');
......
Markdown is supported
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