Apply code review comments and fix tests
This commit is contained in:
@@ -90,10 +90,10 @@ class ModuleStoreEnum(object):
|
||||
test = -3
|
||||
|
||||
|
||||
class LegacyPublishState(object):
|
||||
class PublishState(object):
|
||||
"""
|
||||
The legacy publish state for a given xblock-- either 'draft', 'private', or 'public'. These states
|
||||
are no longer used in Studio directly, but are still referenced in a few places.
|
||||
are no longer used in Studio, but they are still referenced in a few places in LMS.
|
||||
"""
|
||||
draft = 'draft'
|
||||
private = 'private'
|
||||
@@ -301,10 +301,10 @@ class ModuleStoreRead(object):
|
||||
Returns whether this xblock is draft, public, or private.
|
||||
|
||||
Returns:
|
||||
LegacyPublishState.draft - content is in the process of being edited, but still has a previous
|
||||
PublishState.draft - content is in the process of being edited, but still has a previous
|
||||
version deployed to LMS
|
||||
LegacyPublishState.public - content is locked and deployed to LMS
|
||||
LegacyPublishState.private - content is editable and not deployed to LMS
|
||||
PublishState.public - content is locked and deployed to LMS
|
||||
PublishState.private - content is editable and not deployed to LMS
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -522,7 +522,7 @@ class ModuleStoreReadBase(ModuleStoreRead):
|
||||
"""
|
||||
Returns PublishState.public since this is a read-only store.
|
||||
"""
|
||||
return LegacyPublishState.public
|
||||
return PublishState.public
|
||||
|
||||
def heartbeat(self):
|
||||
"""
|
||||
|
||||
@@ -439,10 +439,10 @@ class MixedModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
|
||||
Returns whether this xblock is draft, public, or private.
|
||||
|
||||
Returns:
|
||||
LegacyPublishState.draft - content is in the process of being edited, but still has a previous
|
||||
PublishState.draft - content is in the process of being edited, but still has a previous
|
||||
version deployed to LMS
|
||||
LegacyPublishState.public - content is locked and deployed to LMS
|
||||
LegacyPublishState.private - content is editable and not deployed to LMS
|
||||
PublishState.public - content is locked and deployed to LMS
|
||||
PublishState.private - content is editable and not deployed to LMS
|
||||
"""
|
||||
course_id = xblock.scope_ids.usage_id.course_key
|
||||
store = self._get_modulestore_for_courseid(course_id)
|
||||
|
||||
@@ -11,7 +11,7 @@ import logging
|
||||
|
||||
from opaque_keys.edx.locations import Location
|
||||
from xmodule.exceptions import InvalidVersionError
|
||||
from xmodule.modulestore import LegacyPublishState, ModuleStoreEnum
|
||||
from xmodule.modulestore import PublishState, ModuleStoreEnum
|
||||
from xmodule.modulestore.exceptions import (
|
||||
ItemNotFoundError, DuplicateItemError, InvalidBranchSetting, DuplicateCourseError
|
||||
)
|
||||
@@ -613,7 +613,7 @@ class DraftModuleStore(MongoModuleStore):
|
||||
return False
|
||||
|
||||
# don't check children if this block has changes (is not public)
|
||||
if self.compute_publish_state(item) != LegacyPublishState.public:
|
||||
if self.compute_publish_state(item) != PublishState.public:
|
||||
return True
|
||||
# if this block doesn't have changes, then check its children
|
||||
elif item.has_children:
|
||||
@@ -792,10 +792,10 @@ class DraftModuleStore(MongoModuleStore):
|
||||
Returns whether this xblock is draft, public, or private.
|
||||
|
||||
Returns:
|
||||
LegacyPublishState.draft - content is in the process of being edited, but still has a previous
|
||||
PublishState.draft - content is in the process of being edited, but still has a previous
|
||||
version deployed to LMS
|
||||
LegacyPublishState.public - content is locked and deployed to LMS
|
||||
LegacyPublishState.private - content is editable and not deployed to LMS
|
||||
PublishState.public - content is locked and deployed to LMS
|
||||
PublishState.private - content is editable and not deployed to LMS
|
||||
"""
|
||||
if getattr(xblock, 'is_draft', False):
|
||||
published_xblock_location = as_published(xblock.location)
|
||||
@@ -803,11 +803,11 @@ class DraftModuleStore(MongoModuleStore):
|
||||
{'_id': published_xblock_location.to_deprecated_son()}
|
||||
)
|
||||
if published_item is None:
|
||||
return LegacyPublishState.private
|
||||
return PublishState.private
|
||||
else:
|
||||
return LegacyPublishState.draft
|
||||
return PublishState.draft
|
||||
else:
|
||||
return LegacyPublishState.public
|
||||
return PublishState.public
|
||||
|
||||
def _verify_branch_setting(self, expected_branch_setting):
|
||||
"""
|
||||
|
||||
@@ -4,7 +4,7 @@ Module for the dual-branch fall-back Draft->Published Versioning ModuleStore
|
||||
|
||||
from ..exceptions import ItemNotFoundError
|
||||
from split import SplitMongoModuleStore, EXCLUDE_ALL
|
||||
from xmodule.modulestore import ModuleStoreEnum, LegacyPublishState
|
||||
from xmodule.modulestore import ModuleStoreEnum, PublishState
|
||||
from xmodule.modulestore.exceptions import InsufficientSpecificationError
|
||||
from xmodule.modulestore.draft_and_published import ModuleStoreDraftAndPublished, DIRECT_ONLY_CATEGORIES, UnsupportedRevisionError
|
||||
|
||||
@@ -251,9 +251,9 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
|
||||
Returns whether this xblock is draft, public, or private.
|
||||
|
||||
Returns:
|
||||
LegacyPublishState.draft - published exists and is different from draft
|
||||
LegacyPublishState.public - published exists and is the same as draft
|
||||
LegacyPublishState.private - no published version exists
|
||||
PublishState.draft - published exists and is different from draft
|
||||
PublishState.public - published exists and is the same as draft
|
||||
PublishState.private - no published version exists
|
||||
"""
|
||||
# TODO figure out what to say if xblock is not from the HEAD of its branch
|
||||
def get_head(branch):
|
||||
@@ -272,13 +272,13 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
|
||||
|
||||
if not published_head:
|
||||
# published version does not exist
|
||||
return LegacyPublishState.private
|
||||
return PublishState.private
|
||||
elif get_version(draft_head) == get_version(published_head):
|
||||
# published and draft versions are equal
|
||||
return LegacyPublishState.public
|
||||
return PublishState.public
|
||||
else:
|
||||
# published and draft versions differ
|
||||
return LegacyPublishState.draft
|
||||
return PublishState.draft
|
||||
|
||||
def convert_to_draft(self, location, user_id):
|
||||
"""
|
||||
|
||||
@@ -9,7 +9,7 @@ from pytz import UTC
|
||||
|
||||
from xmodule.tests import DATA_DIR
|
||||
from opaque_keys.edx.locations import Location
|
||||
from xmodule.modulestore import ModuleStoreEnum, LegacyPublishState
|
||||
from xmodule.modulestore import ModuleStoreEnum, PublishState
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError
|
||||
from xmodule.exceptions import InvalidVersionError
|
||||
|
||||
@@ -991,22 +991,22 @@ class TestMixedModuleStore(unittest.TestCase):
|
||||
item_location = item.location.version_agnostic()
|
||||
mongo_store = self.store._get_modulestore_for_courseid(self._course_key_from_string(self.MONGO_COURSEID))
|
||||
with check_mongo_calls(mongo_store, max_find, max_send):
|
||||
self.assertEquals(self.store.compute_publish_state(item), LegacyPublishState.private)
|
||||
self.assertEquals(self.store.compute_publish_state(item), PublishState.private)
|
||||
|
||||
# Private -> Public
|
||||
self.store.publish(item_location, self.user_id)
|
||||
item = self.store.get_item(item_location)
|
||||
self.assertEquals(self.store.compute_publish_state(item), LegacyPublishState.public)
|
||||
self.assertEquals(self.store.compute_publish_state(item), PublishState.public)
|
||||
|
||||
# Public -> Private
|
||||
self.store.unpublish(item_location, self.user_id)
|
||||
item = self.store.get_item(item_location)
|
||||
self.assertEquals(self.store.compute_publish_state(item), LegacyPublishState.private)
|
||||
self.assertEquals(self.store.compute_publish_state(item), PublishState.private)
|
||||
|
||||
# Private -> Public
|
||||
self.store.publish(item_location, self.user_id)
|
||||
item = self.store.get_item(item_location)
|
||||
self.assertEquals(self.store.compute_publish_state(item), LegacyPublishState.public)
|
||||
self.assertEquals(self.store.compute_publish_state(item), PublishState.public)
|
||||
|
||||
# Public -> Draft with NO changes
|
||||
# Note: This is where Split and Mongo differ
|
||||
@@ -1014,14 +1014,14 @@ class TestMixedModuleStore(unittest.TestCase):
|
||||
item = self.store.get_item(item_location)
|
||||
self.assertEquals(
|
||||
self.store.compute_publish_state(item),
|
||||
LegacyPublishState.draft if default_ms == 'draft' else LegacyPublishState.public
|
||||
PublishState.draft if default_ms == 'draft' else PublishState.public
|
||||
)
|
||||
|
||||
# Draft WITH changes
|
||||
item.display_name = 'new name'
|
||||
item = self.store.update_item(item, self.user_id)
|
||||
self.assertTrue(self.store.has_changes(item.location))
|
||||
self.assertEquals(self.store.compute_publish_state(item), LegacyPublishState.draft)
|
||||
self.assertEquals(self.store.compute_publish_state(item), PublishState.draft)
|
||||
|
||||
@ddt.data('draft', 'split')
|
||||
def test_auto_publish(self, default_ms):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from ..pages.studio.auto_auth import AutoAuthPage
|
||||
from ..fixtures.course import CourseFixture
|
||||
from acceptance.tests.helpers import UniqueCourseTest
|
||||
from .helpers import UniqueCourseTest
|
||||
|
||||
|
||||
|
||||
class StudioCourseTest(UniqueCourseTest):
|
||||
|
||||
@@ -25,7 +25,7 @@ from ..pages.studio.signup import SignupPage
|
||||
from ..pages.studio.textbooks import TextbooksPage
|
||||
from ..fixtures.course import XBlockFixtureDesc
|
||||
|
||||
from acceptance.tests.base_studio_test import StudioCourseTest
|
||||
from .base_studio_test import StudioCourseTest
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
|
||||
@@ -8,7 +8,7 @@ from ..pages.studio.overview import CourseOutlinePage, ContainerPage, ExpandColl
|
||||
from ..pages.lms.courseware import CoursewarePage
|
||||
from ..fixtures.course import XBlockFixtureDesc
|
||||
|
||||
from acceptance.tests.base_studio_test import StudioCourseTest
|
||||
from .base_studio_test import StudioCourseTest
|
||||
|
||||
|
||||
class CourseOutlineTest(StudioCourseTest):
|
||||
|
||||
@@ -20,7 +20,7 @@ from ..pages.studio.utils import add_advanced_component
|
||||
from ..pages.studio.unit import UnitPage
|
||||
from ..pages.xblock.utils import wait_for_xblock_initialization
|
||||
|
||||
from acceptance.tests.base_studio_test import StudioCourseTest
|
||||
from .base_studio_test import StudioCourseTest
|
||||
|
||||
from test_studio_container import ContainerBase
|
||||
|
||||
|
||||
Reference in New Issue
Block a user