Skip to content

Commit

Permalink
Merge pull request #2466 from edx/christina/move-tests
Browse files Browse the repository at this point in the history
Move tests related to views files into views/tests.
  • Loading branch information
Christina Roberts committed Feb 10, 2014
2 parents ce5fd88 + fc1e8fa commit 4f69658
Show file tree
Hide file tree
Showing 15 changed files with 11 additions and 42 deletions.
1 change: 0 additions & 1 deletion cms/djangoapps/contentstore/transcripts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from xmodule.contentstore.content import StaticContent
from xmodule.contentstore.django import contentstore
from xmodule.modulestore import Location
from xmodule.modulestore.inheritance import own_metadata

from .utils import get_modulestore

Expand Down
3 changes: 0 additions & 3 deletions cms/djangoapps/contentstore/views/checklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
from django.core.exceptions import PermissionDenied
from xmodule.modulestore.django import loc_mapper

from xmodule.modulestore.inheritance import own_metadata


from ..utils import get_modulestore
from .access import has_course_access
from xmodule.course_module import CourseDescriptor
Expand Down
1 change: 0 additions & 1 deletion cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from xmodule.error_module import ErrorDescriptor
from xmodule.modulestore.django import modulestore, loc_mapper
from xmodule.modulestore.inheritance import own_metadata
from xmodule.contentstore.content import StaticContent

from xmodule.modulestore.exceptions import (
Expand Down
2 changes: 0 additions & 2 deletions cms/djangoapps/contentstore/views/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from django_future.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_http_methods
from edxmako.shortcuts import render_to_response
from xmodule.modulestore import Location
from xmodule.modulestore.inheritance import own_metadata
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.django import loc_mapper
from xmodule.modulestore.locator import BlockUsageLocator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from student.auth import add_users
from contentstore.views.access import get_user_role


class RolesTest(TestCase):
"""
Tests for user roles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from io import BytesIO
from pytz import UTC
import json
from .utils import CourseTestCase
from contentstore.tests.utils import CourseTestCase
from contentstore.views import assets
from xmodule.contentstore.content import StaticContent
from xmodule.modulestore import Location
Expand Down Expand Up @@ -114,6 +114,7 @@ def assert_correct_sort_response(self, url, sort, direction):
self.assertGreaterEqual(name1, name2)
self.assertGreaterEqual(name2, name3)


class UploadTestCase(AssetsTestCase):
"""
Unit tests for uploading a file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
""" Unit tests for checklist methods in views.py. """
from contentstore.utils import get_modulestore
from contentstore.views.checklist import expand_checklist_action_url
from xmodule.modulestore.inheritance import own_metadata
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.django import loc_mapper

import json
from .utils import CourseTestCase
from contentstore.tests.utils import CourseTestCase


class ChecklistTestCase(CourseTestCase):
Expand Down Expand Up @@ -113,7 +112,6 @@ def test_update_checklists_index(self):
self.assertEqual('CourseOutline', get_first_item(persisted_checklist).get('action_url'))
self.compare_checklists(persisted_checklist, returned_checklist)


def test_update_checklists_delete_unsupported(self):
""" Delete operation is not supported. """
update_url = self.location.url_reverse('checklists/', '100')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.modulestore import parsers


class TestCourseIndex(CourseTestCase):
"""
Unit tests for getting the list of courses and the course outline.
Expand All @@ -25,7 +26,6 @@ def setUp(self):
display_name='dotted.course.name-2',
)


def check_index_and_outline(self, authed_client):
"""
Test getting the list of courses and then pulling up their outlines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def get_response(content, date):
content, json.loads(refetched.content)['content'], "get w/ provided id"
)


# now put in an evil update
content = '<ol/>'
payload = get_response(content, 'January 11, 2013')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from uuid import uuid4
from pymongo import MongoClient

from .utils import CourseTestCase
from contentstore.tests.utils import CourseTestCase
from django.test.utils import override_settings
from django.conf import settings
from xmodule.modulestore.django import loc_mapper
Expand All @@ -25,6 +25,7 @@

log = logging.getLogger(__name__)


@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
class ImportTestCase(CourseTestCase):
"""
Expand Down Expand Up @@ -178,7 +179,7 @@ def test_unsafe_tar(self):

def try_tar(tarpath):
with open(tarpath) as tar:
args = { "name": tarpath, "course-data": [tar] }
args = {"name": tarpath, "course-data": [tar]}
resp = self.client.post(self.url, args)
self.assertEquals(resp.status_code, 400)
self.assertTrue("SuspiciousFileOperation" in resp.content)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import json
from unittest import TestCase
from .utils import CourseTestCase
from django.core.urlresolvers import reverse
from contentstore.tests.utils import CourseTestCase
from contentstore.utils import get_modulestore
from xmodule.modulestore.inheritance import own_metadata

from contentstore.views.course import (
validate_textbooks_json, validate_textbook_json, TextbookValidationError)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,17 +333,6 @@ def save_subs_to_store(self, subs, subs_id):
del_cached_content(content_location)
return content_location

def remove_subs_from_store(self, subs_id):
"""Remove from store, if transcripts content exists."""
filename = 'subs_{0}.srt.sjson'.format(subs_id)
content_location = StaticContent.compute_location(
self.org, self.number, filename)
try:
content = contentstore().find(content_location)
contentstore().delete(content.get_id())
except NotFoundError:
pass

def test_success_download_youtube(self):
self.item.data = '<video youtube="1:JMD_ifUUfsU" />'
modulestore().update_item(self.item, self.user.id)
Expand Down Expand Up @@ -521,17 +510,6 @@ def save_subs_to_store(self, subs, subs_id):
del_cached_content(content_location)
return content_location

def remove_subs_from_store(self, subs_id):
"""Remove from store, if transcripts content exists."""
filename = 'subs_{0}.srt.sjson'.format(subs_id)
content_location = StaticContent.compute_location(
self.org, self.number, filename)
try:
content = contentstore().find(content_location)
contentstore().delete(content.get_id())
except NotFoundError:
pass

def test_success_download_nonyoutube(self):
subs_id = str(uuid4())
self.item.data = textwrap.dedent("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Tests for contentstore/views/user.py.
"""
import json
from .utils import CourseTestCase
from django.contrib.auth.models import User, Group
from contentstore.tests.utils import CourseTestCase
from django.contrib.auth.models import User
from student.models import CourseEnrollment
from xmodule.modulestore.django import loc_mapper
from student.roles import CourseStaffRole, CourseInstructorRole
Expand Down

0 comments on commit 4f69658

Please sign in to comment.