Commit 569edd21 by Nimisha Asthagiri

fixup! fix quality issues.

parent c2cf9ae0
...@@ -905,7 +905,6 @@ class ModuleStoreRead(ModuleStoreAssetBase): ...@@ -905,7 +905,6 @@ class ModuleStoreRead(ModuleStoreAssetBase):
""" """
pass pass
@abstractmethod @abstractmethod
def make_course_usage_key(self, course_key): def make_course_usage_key(self, course_key):
""" """
......
...@@ -15,6 +15,7 @@ from opaque_keys.edx.keys import UsageKey ...@@ -15,6 +15,7 @@ from opaque_keys.edx.keys import UsageKey
from transformers.student_view import StudentViewTransformer from transformers.student_view import StudentViewTransformer
from transformers.block_counts import BlockCountsTransformer from transformers.block_counts import BlockCountsTransformer
class ListField(Field): class ListField(Field):
""" """
Field for a list of strings Field for a list of strings
...@@ -26,7 +27,7 @@ class BlockListGetForm(Form): ...@@ -26,7 +27,7 @@ class BlockListGetForm(Form):
""" """
A form to validate query parameters in the block list retrieval endpoint A form to validate query parameters in the block list retrieval endpoint
""" """
user = CharField(required=True) # TODO return all blocks if user is not specified by requesting staff user user = CharField(required=True) # TODO return all blocks if user is not specified by requesting staff user
usage_key = CharField(required=True) usage_key = CharField(required=True)
requested_fields = ListField(required=False) requested_fields = ListField(required=False)
student_view_data = ListField(required=False) student_view_data = ListField(required=False)
...@@ -59,7 +60,6 @@ class BlockListGetForm(Form): ...@@ -59,7 +60,6 @@ class BlockListGetForm(Form):
return usage_key return usage_key
def clean(self): def clean(self):
cleaned_data = super(BlockListGetForm, self).clean() cleaned_data = super(BlockListGetForm, self).clean()
......
...@@ -312,4 +312,4 @@ def create_location(org, course, run, block_type, block_id): ...@@ -312,4 +312,4 @@ def create_location(org, course, run, block_type, block_id):
Returns the usage key for the given key parameters using the Returns the usage key for the given key parameters using the
default modulestore default modulestore
""" """
return modulestore().make_course_key(org, course, run).make_usage_key(block_type, block_id) return modulestore().make_course_key(org, course, run).make_usage_key(block_type, block_id)
\ No newline at end of file
...@@ -48,7 +48,7 @@ class SplitTestTransformerTestCase(CourseStructureTestCase): ...@@ -48,7 +48,7 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
CourseEnrollmentFactory.create(user=self.user, course_id=self.course.id, is_active=True) CourseEnrollmentFactory.create(user=self.user, course_id=self.course.id, is_active=True)
self.transformer = UserPartitionTransformer() self.transformer = UserPartitionTransformer()
def get_course_hierarchy(self): def get_course_hierarchy(self):
""" """
Get a course hierarchy to test with. Get a course hierarchy to test with.
...@@ -156,7 +156,7 @@ class SplitTestTransformerTestCase(CourseStructureTestCase): ...@@ -156,7 +156,7 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
{ {
'#type': 'vertical', '#type': 'vertical',
'#ref': 'L', '#ref': 'L',
'#children': [{'#type': 'vertical', '#ref': 'P',},], '#children': [{'#type': 'vertical', '#ref': 'P'}],
}, },
], ],
}, },
......
...@@ -39,7 +39,7 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase): ...@@ -39,7 +39,7 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
scheme=CohortPartitionScheme scheme=CohortPartitionScheme
) )
self.user_partition.scheme.name = "cohort" self.user_partition.scheme.name = "cohort"
# Build course. # Build course.
self.course_hierarchy = self.get_course_hierarchy() self.course_hierarchy = self.get_course_hierarchy()
self.blocks = self.build_course(self.course_hierarchy) self.blocks = self.build_course(self.course_hierarchy)
...@@ -173,7 +173,7 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase): ...@@ -173,7 +173,7 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
Test when user is assigned to group in user partition. Test when user is assigned to group in user partition.
""" """
if group_id: if group_id:
add_user_to_cohort(self.cohorts[group_id-1], self.user.username) add_user_to_cohort(self.cohorts[group_id - 1], self.user.username)
trans_block_structure = get_course_blocks( trans_block_structure = get_course_blocks(
self.user, self.user,
......
...@@ -6,6 +6,7 @@ from openedx.core.lib.block_cache.transformer import BlockStructureTransformer ...@@ -6,6 +6,7 @@ from openedx.core.lib.block_cache.transformer import BlockStructureTransformer
from .split_test import SplitTestTransformer from .split_test import SplitTestTransformer
from .utils import get_field_on_block from .utils import get_field_on_block
class MergedGroupAccess(object): class MergedGroupAccess(object):
""" """
... ...
......
...@@ -129,7 +129,7 @@ def traverse_post_order(start_node, get_children, get_result=None, predicate=Non ...@@ -129,7 +129,7 @@ def traverse_post_order(start_node, get_children, get_result=None, predicate=Non
while stack: while stack:
# peek at the next item in the stack # peek at the next item in the stack
current_stack_item = stack[len(stack)-1] current_stack_item = stack[len(stack) - 1]
# verify the block wasn't already visited and the block satisfies the predicate # verify the block wasn't already visited and the block satisfies the predicate
if current_stack_item.block in visited or not predicate(current_stack_item.block): if current_stack_item.block in visited or not predicate(current_stack_item.block):
......
...@@ -30,7 +30,7 @@ class TestBlockCache(TestCase, ChildrenMapTestMixin): ...@@ -30,7 +30,7 @@ class TestBlockCache(TestCase, ChildrenMapTestMixin):
block_structure.topological_traversal( block_structure.topological_traversal(
get_result=lambda block_key: block_structure.set_transformer_block_data( get_result=lambda block_key: block_structure.set_transformer_block_data(
block_key, self, self.block_key(), self.block_val(block_key) block_key, self, self.block_key(), self.block_val(block_key)
))) )))
def transform(self, user_info, block_structure): def transform(self, user_info, block_structure):
def assert_collected_value(block_key): def assert_collected_value(block_key):
...@@ -45,7 +45,7 @@ class TestBlockCache(TestCase, ChildrenMapTestMixin): ...@@ -45,7 +45,7 @@ class TestBlockCache(TestCase, ChildrenMapTestMixin):
list( list(
block_structure.topological_traversal( block_structure.topological_traversal(
get_result=lambda block_key: assert_collected_value(block_key) get_result=lambda block_key: assert_collected_value(block_key)
)) ))
def setUp(self): def setUp(self):
super(TestBlockCache, self).setUp() super(TestBlockCache, self).setUp()
......
...@@ -35,11 +35,11 @@ class TestBlockStructure(TestCase, ChildrenMapTestMixin): ...@@ -35,11 +35,11 @@ class TestBlockStructure(TestCase, ChildrenMapTestMixin):
# get_children # get_children
for parent, children in enumerate(children_map): for parent, children in enumerate(children_map):
self.assertSetEqual(set(block_structure.get_children(parent)), set(children)) self.assertSetEqual(set(block_structure.get_children(parent)), set(children))
# get_parents # get_parents
for child, parents in enumerate(self.get_parents_map(children_map)): for child, parents in enumerate(self.get_parents_map(children_map)):
self.assertSetEqual(set(block_structure.get_parents(child)), set(parents)) self.assertSetEqual(set(block_structure.get_parents(child)), set(parents))
# has_block # has_block
for node in range(len(children_map)): for node in range(len(children_map)):
...@@ -68,7 +68,7 @@ class TestBlockStructureData(TestCase, ChildrenMapTestMixin): ...@@ -68,7 +68,7 @@ class TestBlockStructureData(TestCase, ChildrenMapTestMixin):
transformers_info = [ transformers_info = [
TransformerInfo( TransformerInfo(
transformer=MockTransformer(), transformer=MockTransformer(),
structure_wide_data=[("t1.global1", "t1.g.val1"), ("t1.global2", "t1.g.val2"),], structure_wide_data=[("t1.global1", "t1.g.val1"), ("t1.global2", "t1.g.val2")],
block_specific_data={ block_specific_data={
"B1": [("t1.key1", "t1.b1.val1"), ("t1.key2", "t1.b1.val2")], "B1": [("t1.key1", "t1.b1.val1"), ("t1.key2", "t1.b1.val2")],
"B2": [("t1.key1", "t1.b2.val1"), ("t1.key2", "t1.b2.val2")], "B2": [("t1.key1", "t1.b2.val1"), ("t1.key2", "t1.b2.val2")],
...@@ -78,7 +78,7 @@ class TestBlockStructureData(TestCase, ChildrenMapTestMixin): ...@@ -78,7 +78,7 @@ class TestBlockStructureData(TestCase, ChildrenMapTestMixin):
), ),
TransformerInfo( TransformerInfo(
transformer=MockTransformer(), transformer=MockTransformer(),
structure_wide_data=[("t2.global1", "t2.g.val1"), ("t2.global2", "t2.g.val2"),], structure_wide_data=[("t2.global1", "t2.g.val1"), ("t2.global2", "t2.g.val2")],
block_specific_data={ block_specific_data={
"B1": [("t2.key1", "t2.b1.val1"), ("t2.key2", "t2.b1.val2")], "B1": [("t2.key1", "t2.b1.val1"), ("t2.key2", "t2.b1.val2")],
"B2": [("t2.key1", "t2.b2.val1"), ("t2.key2", "t2.b2.val2")], "B2": [("t2.key1", "t2.b2.val1"), ("t2.key2", "t2.b2.val2")],
......
...@@ -147,7 +147,7 @@ class GraphTraversalsTestCase(TestCase): ...@@ -147,7 +147,7 @@ class GraphTraversalsTestCase(TestCase):
# / | \ / \ # / | \ / \
# M N O P # M N O P
graph = { graph = {
'root': ['A', 'B', 'C', 'E', 'F', 'K', 'O'], # has additional links than what is drawn above 'root': ['A', 'B', 'C', 'E', 'F', 'K', 'O'], # has additional links than what is drawn above
'A': ['D', 'E'], 'A': ['D', 'E'],
'B': ['E', 'F', 'G'], 'B': ['E', 'F', 'G'],
'C': ['H', 'I'], 'C': ['H', 'I'],
...@@ -166,7 +166,7 @@ class GraphTraversalsTestCase(TestCase): ...@@ -166,7 +166,7 @@ class GraphTraversalsTestCase(TestCase):
'P': [], 'P': [],
} }
graph_parents = self.get_parent_map(graph) graph_parents = self.get_parent_map(graph)
for _ in range(2): # should get the same result twice for _ in range(2): # should get the same result twice
self.assertEqual( self.assertEqual(
list(traverse_topologically( list(traverse_topologically(
start_node='root', start_node='root',
......
...@@ -74,6 +74,7 @@ class MockUserInfo(object): ...@@ -74,6 +74,7 @@ class MockUserInfo(object):
class MockTransformer(BlockStructureTransformer): class MockTransformer(BlockStructureTransformer):
VERSION = 1 VERSION = 1
def transform(self, user_info, block_structure): def transform(self, user_info, block_structure):
pass pass
...@@ -111,7 +112,7 @@ class ChildrenMapTestMixin(object): ...@@ -111,7 +112,7 @@ class ChildrenMapTestMixin(object):
# add_relation # add_relation
for parent, children in enumerate(children_map): for parent, children in enumerate(children_map):
for child in children: for child in children:
block_structure.add_relation(parent, child) block_structure.add_relation(parent, child)
return block_structure return block_structure
def get_parents_map(self, children_map): def get_parents_map(self, children_map):
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
""" """
from abc import abstractproperty from abc import abstractproperty
class UserInfo(object): class UserInfo(object):
""" """
... ...
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment