Small fixes to LMS unit 1 failures in Django 1.11 tests

This commit is contained in:
bmedx
2018-01-04 15:14:57 -05:00
parent 792d0db5da
commit 95e76dcafe
5 changed files with 12 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
Tests for the Badges app models.
"""
import pytest
from path import Path
from django.core.exceptions import ValidationError
from django.core.files.images import ImageFile
from django.core.files.storage import default_storage
@@ -33,10 +34,14 @@ def get_image(name):
@attr(shard=1)
@override_settings(MEDIA_ROOT=TEST_DATA_ROOT)
class BadgeImageConfigurationTest(TestCase):
"""
Test the validation features of BadgeImageConfiguration.
"""
def tearDown(self):
tmp_path = Path(TEST_DATA_ROOT / 'course_complete_badges')
Path.rmtree_p(tmp_path)
@pytest.mark.django111_expected_failure
def test_no_double_default(self):
@@ -66,6 +71,7 @@ class DummyBackend(object):
award = Mock()
@override_settings(MEDIA_ROOT=TEST_DATA_ROOT)
class BadgeClassTest(ModuleStoreTestCase):
"""
Test BadgeClass functionality
@@ -157,7 +163,7 @@ class BadgeClassTest(ModuleStoreTestCase):
self.assertEqual(badge_class.description, 'This is a test')
self.assertEqual(badge_class.criteria, 'https://example.com/test_criteria')
self.assertEqual(badge_class.display_name, 'Super Badge')
self.assertEqual(badge_class.image.name.rsplit('/', 1)[-1], 'good.png')
self.assertTrue('good' in badge_class.image.name.rsplit('/', 1)[-1])
def test_get_badge_class_nocreate(self):
"""

View File

@@ -173,7 +173,7 @@ class TestLTIModuleListing(SharedModuleStoreTestCase):
def expected_handler_url(self, handler):
"""convenience method to get the reversed handler urls"""
return "https://{}{}".format(settings.SITE_NAME, reverse(
'courseware.module_render.handle_xblock_callback_noauth',
'xblock_handler_noauth',
args=[
self.course.id.to_deprecated_string(),
quote_slashes(unicode(self.lti_published.scope_ids.usage_id.to_deprecated_string()).encode('utf-8')),

View File

@@ -248,6 +248,7 @@ class ModuleRenderTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
)
# Verify that handle ajax is called with the correct data
request.POST._mutable = True
request.POST['queuekey'] = fake_key
self.mock_module.handle_ajax.assert_called_once_with(self.dispatch, request.POST)

View File

@@ -89,6 +89,9 @@ class Bookmark(TimeStampedModel):
user = data.pop('user')
# Sometimes this ends up in data, but newer versions of Django will fail on having unknown keys in defaults
data.pop('display_name', None)
bookmark, created = cls.objects.get_or_create(usage_key=usage_key, user=user, defaults=data)
return bookmark, created

View File

@@ -23,7 +23,6 @@ class BookmarkFactory(DjangoModelFactory):
user = factory.SubFactory(UserFactory)
course_key = COURSE_KEY
usage_key = LOCATION('usage_id')
path = list()
xblock_cache = factory.SubFactory(
'openedx.core.djangoapps.bookmarks.tests.factories.XBlockCacheFactory',
course_key=factory.SelfAttribute('..course_key'),