From f925a4af9c57f085f983d04b58899d45ee46ca40 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 26 Aug 2015 16:57:42 -0400 Subject: [PATCH 1/2] Move recommender XBlock tests to openedx/tests/xblock_integration I want to make clear that these tests rely on XBlocks in other repos, and that ideally in time we would move these tests into the XBlock repo. --- openedx/tests/__init__.py | 0 openedx/tests/xblock_integration/__init__.py | 7 +++++++ .../tests/xblock_integration}/test_recommender.py | 0 pavelib/utils/test/suites/nose_suite.py | 15 +++++++++------ 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 openedx/tests/__init__.py create mode 100644 openedx/tests/xblock_integration/__init__.py rename {lms/djangoapps/courseware/tests => openedx/tests/xblock_integration}/test_recommender.py (100%) diff --git a/openedx/tests/__init__.py b/openedx/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/openedx/tests/xblock_integration/__init__.py b/openedx/tests/xblock_integration/__init__.py new file mode 100644 index 0000000000..66adf2540e --- /dev/null +++ b/openedx/tests/xblock_integration/__init__.py @@ -0,0 +1,7 @@ +"""Tests of XBlocks integrated with edx-platform. + +These tests exercise XBlocks which may live in other repos, to confirm both +that the XBlock works, and that edx-platform continues to properly support the +XBlock. + +""" diff --git a/lms/djangoapps/courseware/tests/test_recommender.py b/openedx/tests/xblock_integration/test_recommender.py similarity index 100% rename from lms/djangoapps/courseware/tests/test_recommender.py rename to openedx/tests/xblock_integration/test_recommender.py diff --git a/pavelib/utils/test/suites/nose_suite.py b/pavelib/utils/test/suites/nose_suite.py index 5dab89cdbc..7531ebf48f 100644 --- a/pavelib/utils/test/suites/nose_suite.py +++ b/pavelib/utils/test/suites/nose_suite.py @@ -145,20 +145,23 @@ class SystemTestSuite(NoseTestSuite): # django-nose will import them early in the test process, # thereby making sure that we load any django models that are # only defined in test files. - default_test_id = "{system}/djangoapps/* common/djangoapps/* openedx/core/djangoapps/*".format( - system=self.root + default_test_id = ( + "{system}/djangoapps/*" + " common/djangoapps/*" + " openedx/core/djangoapps/*" + " openedx/tests/*" ) if self.root in ('lms', 'cms'): - default_test_id += " {system}/lib/*".format(system=self.root) + default_test_id += " {system}/lib/*" if self.root == 'lms': - default_test_id += " {system}/tests.py".format(system=self.root) + default_test_id += " {system}/tests.py" if self.root == 'cms': - default_test_id += " {system}/tests/*".format(system=self.root) + default_test_id += " {system}/tests/*" - return default_test_id + return default_test_id.format(system=self.root) class LibTestSuite(NoseTestSuite): From a16c951c0975c529d1434845c6bf25e4d3baf0cd Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 27 Aug 2015 07:20:44 -0400 Subject: [PATCH 2/2] Fix imports and test skips to work properly from openedx --- .../xblock_integration/test_recommender.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/openedx/tests/xblock_integration/test_recommender.py b/openedx/tests/xblock_integration/test_recommender.py index b16be8cd01..dea42322d6 100644 --- a/openedx/tests/xblock_integration/test_recommender.py +++ b/openedx/tests/xblock_integration/test_recommender.py @@ -2,21 +2,24 @@ This test file will run through some XBlock test scenarios regarding the recommender system """ + +from copy import deepcopy import json import itertools import StringIO +import unittest + from ddt import ddt, data -from copy import deepcopy from nose.plugins.attrib import attr +from django.conf import settings from django.core.urlresolvers import reverse from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from courseware.tests.helpers import LoginEnrollmentTestCase -from courseware.tests.factories import GlobalStaffFactory - +from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase +from lms.djangoapps.courseware.tests.factories import GlobalStaffFactory from lms.djangoapps.lms_xblock.runtime import quote_slashes @@ -32,6 +35,12 @@ class TestRecommender(SharedModuleStoreTestCase, LoginEnrollmentTestCase): @classmethod def setUpClass(cls): + # Nose runs setUpClass methods even if a class decorator says to skip + # the class: https://github.com/nose-devs/nose/issues/946 + # So, skip the test class here if we are not in the LMS. + if settings.ROOT_URLCONF != 'lms.urls': + raise unittest.SkipTest('Test only valid in lms') + super(TestRecommender, cls).setUpClass() cls.course = CourseFactory.create( display_name='Recommender_Test_Course'