def test_add_milestone_inactive_milestone_with_relationships_propagate_false(self): """ Unit Test: test_add_milestone_inactive_milestone_with_relationships_propagate_false""" milestone_data = { 'name': 'local_milestone', 'display_name': 'Local Milestone', 'namespace': six.text_type(self.test_course_key), 'description': 'Local Milestone Description' } milestone = api.add_milestone(milestone_data) api.add_course_milestone( self.test_course_key, self.relationship_types['REQUIRES'], milestone ) api.add_course_content_milestone( self.test_course_key, self.test_content_key, self.relationship_types['FULFILLS'], milestone ) api.add_user_milestone(self.serialized_test_user, milestone) self.assertGreater(milestone['id'], 0) api.remove_milestone(milestone['id']) with self.assertNumQueries(3): milestone = api.add_milestone(milestone_data, propagate=False)
def test_remove_milestone_bogus_milestone(self): """ Unit Test: test_remove_milestone_bogus_milestone """ with self.assertNumQueries(5): api.remove_milestone(self.test_milestone['id']) with self.assertRaises(exceptions.InvalidMilestoneException): api.get_milestone(self.test_milestone['id']) # Do it again with the valid id to hit the exception workflow with self.assertNumQueries(4): api.remove_milestone(self.test_milestone['id']) with self.assertRaises(exceptions.InvalidMilestoneException): api.get_milestone(self.test_milestone['id'])
def test_add_milestone_inactive_to_active(self): """ Unit Test: test_add_milestone_inactive_to_active """ milestone_data = { 'name': 'local_milestone', 'display_name': 'Local Milestone', 'namespace': six.text_type(self.test_course_key), 'description': 'Local Milestone Description' } milestone = api.add_milestone(milestone_data) self.assertGreater(milestone['id'], 0) api.remove_milestone(milestone['id']) with self.assertNumQueries(6): milestone = api.add_milestone(milestone_data)
def test_add_milestone_inactive_to_active(self): """ Unit Test: test_add_milestone_inactive_to_active """ milestone_data = { 'name': 'local_milestone', 'display_name': 'Local Milestone', 'namespace': unicode(self.test_course_key), 'description': 'Local Milestone Description' } milestone = api.add_milestone(milestone_data) self.assertGreater(milestone['id'], 0) api.remove_milestone(milestone['id']) with self.assertNumQueries(6): milestone = api.add_milestone(milestone_data)
def remove_prerequisite(prereq_content_key): """ Removes the Milestone and CourseContentMilestones related to the gating prerequisite which the given course content fulfills Arguments: prereq_content_key (str|UsageKey): The prerequisite content usage key Returns: None """ milestones = milestones_api.get_milestones("{usage_key}{qualifier}".format( usage_key=prereq_content_key, qualifier=GATING_NAMESPACE_QUALIFIER)) for milestone in milestones: milestones_api.remove_milestone(milestone.get('id'))
def remove_prerequisite(prereq_content_key): """ Removes the Milestone and CourseContentMilestones related to the gating prerequisite which the given course content fulfills Arguments: prereq_content_key (str|UsageKey): The prerequisite content usage key Returns: None """ milestones = milestones_api.get_milestones("{usage_key}{qualifier}".format( usage_key=prereq_content_key, qualifier=GATING_NAMESPACE_QUALIFIER )) for milestone in milestones: milestones_api.remove_milestone(milestone.get('id'))
def test_add_milestone_inactive_milestone_with_relationships(self): """ Unit Test: test_add_milestone_inactive_milestone_with_relationships""" milestone_data = { 'name': 'local_milestone', 'display_name': 'Local Milestone', 'namespace': unicode(self.test_course_key), 'description': 'Local Milestone Description' } milestone = api.add_milestone(milestone_data) api.add_course_milestone(self.test_course_key, self.relationship_types['REQUIRES'], milestone) api.add_course_content_milestone(self.test_course_key, self.test_content_key, self.relationship_types['FULFILLS'], milestone) api.add_user_milestone(self.serialized_test_user, milestone) self.assertGreater(milestone['id'], 0) api.remove_milestone(milestone['id']) with self.assertNumQueries(9): milestone = api.add_milestone(milestone_data)
def test_remove_milestone(self): """ Unit Test: test_remove_milestone """ with self.assertNumQueries(5): api.remove_milestone(self.test_milestone['id']) with self.assertRaises(exceptions.InvalidMilestoneException): api.get_milestone(self.test_milestone['id'])