From 03256937e659907402d7d1e3abb95655149994c4 Mon Sep 17 00:00:00 2001 From: Sanford Student Date: Thu, 28 Jul 2016 11:13:47 -0400 Subject: [PATCH] fixing failing tests on master from enabling milestones_app feature flag --- lms/djangoapps/courseware/features/common.py | 9 ++++++++- lms/djangoapps/courseware/tests/test_masquerade.py | 3 ++- lms/djangoapps/courseware/tests/test_module_render.py | 2 +- lms/djangoapps/courseware/tests/test_navigation.py | 3 ++- lms/djangoapps/courseware/tests/test_split_module.py | 3 ++- lms/djangoapps/courseware/tests/test_views.py | 10 +++++----- openedx/tests/xblock_integration/test_done.py | 4 ++++ 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lms/djangoapps/courseware/features/common.py b/lms/djangoapps/courseware/features/common.py index 832fb46173..cda3109149 100644 --- a/lms/djangoapps/courseware/features/common.py +++ b/lms/djangoapps/courseware/features/common.py @@ -5,10 +5,11 @@ from __future__ import absolute_import import time -from lettuce import world, step +from lettuce import world, step, before from lettuce.django import django_url from django.contrib.auth.models import User from django.core.urlresolvers import reverse +from milestones.models import MilestoneRelationshipType from student.models import CourseEnrollment from xmodule.modulestore.django import modulestore from xmodule.course_module import CourseDescriptor @@ -18,6 +19,12 @@ from logging import getLogger logger = getLogger(__name__) +@before.each_scenario # pylint: disable=no-member +def setup_milestones_app(scenario): # pylint: disable=unused-argument + MilestoneRelationshipType.objects.get_or_create(name='requires') + MilestoneRelationshipType.objects.get_or_create(name='fulfills') + + @step('I (.*) capturing of screenshots before and after each step$') def configure_screenshots_for_all_steps(_step, action): """ diff --git a/lms/djangoapps/courseware/tests/test_masquerade.py b/lms/djangoapps/courseware/tests/test_masquerade.py index 8fc5b9de29..7d0018039c 100644 --- a/lms/djangoapps/courseware/tests/test_masquerade.py +++ b/lms/djangoapps/courseware/tests/test_masquerade.py @@ -22,6 +22,7 @@ from courseware.masquerade import ( from courseware.tests.factories import StaffFactory from courseware.tests.helpers import LoginEnrollmentTestCase, get_request_for_user from courseware.tests.test_submitting_problems import ProblemSubmissionTestMixin +from milestones.tests.utils import MilestonesTestCaseMixin from student.tests.factories import UserFactory from xblock.runtime import DictKeyValueStore from xmodule.modulestore.django import modulestore @@ -31,7 +32,7 @@ from xmodule.partitions.partitions import Group, UserPartition from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration -class MasqueradeTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase): +class MasqueradeTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase, MilestonesTestCaseMixin): """ Base class for masquerade tests that sets up a test course and enrolls a user in the course. """ diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index f078157e47..104a8886ba 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -407,7 +407,7 @@ class ModuleRenderTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase): @attr('shard_1') -class TestHandleXBlockCallback(SharedModuleStoreTestCase, LoginEnrollmentTestCase): +class TestHandleXBlockCallback(SharedModuleStoreTestCase, LoginEnrollmentTestCase, MilestonesTestCaseMixin): """ Test the handle_xblock_callback function """ diff --git a/lms/djangoapps/courseware/tests/test_navigation.py b/lms/djangoapps/courseware/tests/test_navigation.py index f61ebf09a6..919ecafaea 100644 --- a/lms/djangoapps/courseware/tests/test_navigation.py +++ b/lms/djangoapps/courseware/tests/test_navigation.py @@ -11,6 +11,7 @@ from django.test.utils import override_settings from courseware.tests.helpers import LoginEnrollmentTestCase from courseware.tests.factories import GlobalStaffFactory +from milestones.tests.utils import MilestonesTestCaseMixin from student.tests.factories import UserFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory @@ -18,7 +19,7 @@ from xmodule.modulestore.django import modulestore @attr('shard_1') -class TestNavigation(SharedModuleStoreTestCase, LoginEnrollmentTestCase): +class TestNavigation(SharedModuleStoreTestCase, LoginEnrollmentTestCase, MilestonesTestCaseMixin): """ Check that navigation state is saved properly. """ diff --git a/lms/djangoapps/courseware/tests/test_split_module.py b/lms/djangoapps/courseware/tests/test_split_module.py index 843a247ffe..6fbb0bb153 100644 --- a/lms/djangoapps/courseware/tests/test_split_module.py +++ b/lms/djangoapps/courseware/tests/test_split_module.py @@ -7,6 +7,7 @@ from nose.plugins.attrib import attr from courseware.module_render import get_module_for_descriptor from courseware.model_data import FieldDataCache +from milestones.tests.utils import MilestonesTestCaseMixin from student.tests.factories import UserFactory, CourseEnrollmentFactory from xmodule.modulestore.tests.factories import ItemFactory, CourseFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase @@ -15,7 +16,7 @@ from openedx.core.djangoapps.user_api.tests.factories import UserCourseTagFactor @attr('shard_1') -class SplitTestBase(SharedModuleStoreTestCase): +class SplitTestBase(SharedModuleStoreTestCase, MilestonesTestCaseMixin): """ Sets up a basic course and user for split test testing. Also provides tests of rendered HTML for two user_tag conditions, 0 and 1. diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 9634deda15..c3b072cb9b 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -191,7 +191,7 @@ class TestJumpTo(ModuleStoreTestCase): @attr('shard_2') @ddt.ddt -class ViewsTestCase(ModuleStoreTestCase): +class ViewsTestCase(ModuleStoreTestCase, MilestonesTestCaseMixin): """ Tests for views.py methods. """ @@ -939,7 +939,7 @@ class ViewsTestCase(ModuleStoreTestCase): @attr('shard_1') # setting TIME_ZONE_DISPLAYED_FOR_DEADLINES explicitly @override_settings(TIME_ZONE_DISPLAYED_FOR_DEADLINES="UTC") -class BaseDueDateTests(ModuleStoreTestCase): +class BaseDueDateTests(ModuleStoreTestCase, MilestonesTestCaseMixin): """ Base class that verifies that due dates are rendered correctly on a page """ @@ -1816,7 +1816,7 @@ class ViewCheckerBlock(XBlock): @attr('shard_1') @ddt.ddt -class TestIndexView(ModuleStoreTestCase): +class TestIndexView(ModuleStoreTestCase, MilestonesTestCaseMixin): """ Tests of the courseware.views.index view. """ @@ -1888,7 +1888,7 @@ class TestIndexView(ModuleStoreTestCase): @ddt.ddt -class TestIndewViewWithVerticalPositions(ModuleStoreTestCase): +class TestIndexViewWithVerticalPositions(ModuleStoreTestCase, MilestonesTestCaseMixin): """ Test the index view to handle vertical positions. Confirms that first position is loaded if input position is non-positive or greater than number of positions available. @@ -1898,7 +1898,7 @@ class TestIndewViewWithVerticalPositions(ModuleStoreTestCase): """ Set up initial test data """ - super(TestIndewViewWithVerticalPositions, self).setUp() + super(TestIndexViewWithVerticalPositions, self).setUp() self.user = UserFactory() diff --git a/openedx/tests/xblock_integration/test_done.py b/openedx/tests/xblock_integration/test_done.py index 057165acd0..a8e8c435cd 100644 --- a/openedx/tests/xblock_integration/test_done.py +++ b/openedx/tests/xblock_integration/test_done.py @@ -4,10 +4,14 @@ Tests for the DoneXBlock. This is nice as a simple example of the edX XBlock test framework. ''' +from mock import patch from openedx.tests.xblock_integration.xblock_testcase import XBlockTestCase +# We set MILESTONES_APP to False to avoid XBlock access issues in this test, +# which is meant to exist independent of our particular LMS instance. # pylint: disable=abstract-method +@patch.dict('django.conf.settings.FEATURES', {'MILESTONES_APP': False}) class TestDone(XBlockTestCase): """ Simple tests for the completion XBlock. We set up a page with two