本文整理汇总了Python中milestones.api.add_milestone函数的典型用法代码示例。如果您正苦于以下问题:Python add_milestone函数的具体用法?Python add_milestone怎么用?Python add_milestone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_milestone函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_fetch_course_content_milestones_invalid_milestone_relationship_type
def test_fetch_course_content_milestones_invalid_milestone_relationship_type(self):
""" Unit Test: test_fetch_course_content_milestones_invalid_milestone_relationship_type"""
milestone1 = api.add_milestone({
'display_name': 'Test Milestone',
'name': 'test_milestone',
'namespace': unicode(self.test_course_key),
'description': 'Test Milestone Description',
})
api.add_course_content_milestone(
self.test_course_key,
self.test_content_key,
self.relationship_types['REQUIRES'],
milestone1
)
milestone2 = api.add_milestone({
'display_name': 'Test Milestone 2',
'name': 'test_milestone2',
'namespace': unicode(self.test_course_key),
'description': 'Test Milestone Description 2',
})
api.add_course_content_milestone(
self.test_course_key,
self.test_content_key,
self.relationship_types['FULFILLS'],
milestone2
)
with self.assertRaises(exceptions.InvalidMilestoneRelationshipTypeException):
data.fetch_course_content_milestones(
self.test_course_key,
self.test_content_key,
'invalid_relationshipppp'
)
开发者ID:GbalsaC,项目名称:bitnamiP,代码行数:32,代码来源:test_data.py
示例2: test_add_milestone_inactive_milestone_with_relationships_propagate_false
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)
开发者ID:edx,项目名称:edx-milestones,代码行数:26,代码来源:test_api.py
示例3: test_add_milestone_active_exists
def test_add_milestone_active_exists(self):
""" Unit Test: test_add_milestone_active_exists"""
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)
with self.assertNumQueries(1):
milestone = api.add_milestone(milestone_data)
开发者ID:edx,项目名称:edx-milestones,代码行数:12,代码来源:test_api.py
示例4: test_add_milestone_invalid_data_throws_exceptions
def test_add_milestone_invalid_data_throws_exceptions(self):
""" Unit Test: test_add_milestone_invalid_namespaces_throw_exceptions"""
with self.assertNumQueries(0):
with self.assertRaises(exceptions.InvalidMilestoneException):
api.add_milestone({
'name': 'local_milestone',
'display_name': 'Local Milestone',
'namespace': '', # Should throw an exception
'description': 'Local Milestone Description'
})
with self.assertNumQueries(0):
with self.assertRaises(exceptions.InvalidMilestoneException):
api.add_milestone({
'name': 'Local Milestone', # Missing namespace should throw exception
'description': 'Local Milestone Description'
})
with self.assertNumQueries(0):
with self.assertRaises(exceptions.InvalidMilestoneException):
api.add_milestone({
'name': '', # Empty name should throw an exception on create
'namespace': 'fixed',
'description': 'Local Milestone Description 2'
})
with self.assertNumQueries(0):
with self.assertRaises(exceptions.InvalidMilestoneException):
api.add_milestone({
'namespace': 'fixed', # Missing name should throw exception
'description': 'Local Milestone Description 2'
})
开发者ID:edx,项目名称:edx-milestones,代码行数:32,代码来源:test_api.py
示例5: test_add_milestone_inactive_to_active
def test_add_milestone_inactive_to_active(self):
""" Unit Test: test_add_milestone_inactive_milestone_present"""
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(5):
milestone = api.add_milestone(milestone_data)
开发者ID:GbalsaC,项目名称:bitnamiP,代码行数:14,代码来源:test_api.py
示例6: add_milestone
def add_milestone(milestone_data):
"""
Client API operation adapter/wrapper
"""
if not settings.FEATURES.get('MILESTONES_APP'):
return None
return milestones_api.add_milestone(milestone_data)
开发者ID:CraftAcademy,项目名称:edx-platform,代码行数:7,代码来源:milestones_helpers.py
示例7: test_is_gate_fulfilled
def test_is_gate_fulfilled(self, min_score, min_completion, learner_score, learner_completion, is_gate_fulfilled):
"""
Test if prereq section has any unfulfilled milestones
"""
student = UserFactory(is_staff=False)
gating_api.add_prerequisite(self.course.id, self.seq1.location)
gating_api.set_required_content(
self.course.id, self.seq2.location, self.seq1.location, min_score, min_completion
)
milestone = milestones_api.add_milestone(self.generic_milestone)
milestones_api.add_course_content_milestone(self.course.id, self.seq1.location, 'fulfills', milestone)
self.assertFalse(gating_api.is_gate_fulfilled(self.course.id, self.seq1.location, student.id))
# complete the prerequisite to unlock the gated content
# this call triggers reevaluation of prerequisites fulfilled by the gating block.
with patch.object(gating_api, 'get_subsection_completion_percentage') as mock_grade:
mock_grade.return_value = learner_completion
lms_gating_api.evaluate_prerequisite(
self.course,
Mock(location=self.seq1.location, percent_graded=learner_score / 100.0),
student,
)
self.assertEqual(
gating_api.is_gate_fulfilled(self.course.id, self.seq1.location, student.id), is_gate_fulfilled
)
开发者ID:mreyk,项目名称:edx-platform,代码行数:26,代码来源:test_api.py
示例8: test_get_courses_milestones
def test_get_courses_milestones(self):
""" Unit Test: test_get_courses_milestones """
api.add_course_milestone(
self.test_course_key,
self.relationship_types['REQUIRES'],
self.test_milestone
)
api.add_course_milestone(
self.test_prerequisite_course_key,
self.relationship_types['REQUIRES'],
self.test_milestone
)
local_milestone = api.add_milestone({
'display_name': 'Local Milestone',
'name': 'local_milestone',
'namespace': unicode(self.test_course_key),
'description': 'Local Milestone Description'
})
api.add_course_milestone(
self.test_course_key,
self.relationship_types['FULFILLS'],
local_milestone
)
with self.assertNumQueries(2):
requirer_milestones = api.get_courses_milestones(
[self.test_course_key, self.test_prerequisite_course_key],
self.relationship_types['REQUIRES']
)
self.assertEqual(len(requirer_milestones), 2)
with self.assertNumQueries(1):
requirer_milestones = api.get_courses_milestones(
[self.test_course_key],
)
self.assertEqual(len(requirer_milestones), 2)
开发者ID:GbalsaC,项目名称:bitnamiP,代码行数:35,代码来源:test_api.py
示例9: test_get_courses_milestones_with_invalid_relationship_type
def test_get_courses_milestones_with_invalid_relationship_type(self):
""" Unit Test: test_get_courses_milestones_with_invalid_relationship_type """
api.add_course_milestone(
self.test_course_key,
self.relationship_types['REQUIRES'],
self.test_milestone
)
api.add_course_milestone(
self.test_prerequisite_course_key,
self.relationship_types['REQUIRES'],
self.test_milestone
)
local_milestone = api.add_milestone({
'display_name': 'Local Milestone',
'name': 'local_milestone',
'namespace': six.text_type(self.test_course_key),
'description': 'Local Milestone Description'
})
api.add_course_milestone(
self.test_course_key,
self.relationship_types['FULFILLS'],
local_milestone
)
with self.assertNumQueries(1):
requirer_milestones = api.get_courses_milestones(
[self.test_course_key],
'INVALID RELATIONSHIP TYPE'
)
self.assertEqual(len(requirer_milestones), 0)
开发者ID:edx,项目名称:edx-milestones,代码行数:30,代码来源:test_api.py
示例10: test_fetch_course_content_milestones_null_keys
def test_fetch_course_content_milestones_null_keys(self):
""" Unit Test: test_fetch_course_content_milestones_null_keys"""
namespace = '{}.entrance_exams'.format(unicode(self.test_course_key))
milestone1 = api.add_milestone({
'display_name': 'Test Milestone',
'name': 'test_milestone',
'namespace': namespace,
'description': 'Test Milestone Description',
})
api.add_course_content_milestone(
self.test_course_key,
self.test_content_key,
self.relationship_types['REQUIRES'],
milestone1
)
milestones = data.fetch_milestones(milestone={'namespace': namespace})
self.assertEqual(len(milestones), 1)
ccms = data.fetch_course_content_milestones(
content_key=self.test_content_key,
course_key=None,
relationship=None
)
self.assertEqual(len(ccms), 1)
ccms = data.fetch_course_content_milestones(
content_key=None,
course_key=self.test_course_key,
relationship=None
)
self.assertEqual(len(ccms), 1)
开发者ID:GbalsaC,项目名称:bitnamiP,代码行数:31,代码来源:test_data.py
示例11: test_get_course_tabs_list_entrance_exam_enabled
def test_get_course_tabs_list_entrance_exam_enabled(self):
"""
Unit Test: test_get_course_tabs_list_entrance_exam_enabled
"""
entrance_exam = ItemFactory.create(
category="chapter", parent_location=self.course.location,
data="Exam Data", display_name="Entrance Exam"
)
entrance_exam.is_entrance_exam = True
milestone = {
'name': 'Test Milestone',
'namespace': '{}.entrance_exams'.format(unicode(self.course.id)),
'description': 'Testing Courseware Tabs'
}
self.course.entrance_exam_enabled = True
self.course.entrance_exam_id = unicode(entrance_exam.location)
milestone = milestones_api.add_milestone(milestone)
milestones_api.add_course_milestone(
unicode(self.course.id),
self.relationship_types['REQUIRES'],
milestone
)
milestones_api.add_course_content_milestone(
unicode(self.course.id),
unicode(entrance_exam.location),
self.relationship_types['FULFILLS'],
milestone
)
course_tab_list = get_course_tab_list(self.course, self.user)
self.assertEqual(len(course_tab_list), 2)
self.assertEqual(course_tab_list[0]['tab_id'], 'courseware')
self.assertEqual(course_tab_list[0]['name'], 'Entrance Exam')
self.assertEqual(course_tab_list[1]['tab_id'], 'instructor')
开发者ID:feedbackfruits,项目名称:edx-platform,代码行数:33,代码来源:test_tabs.py
示例12: add_milestone
def add_milestone(milestone_data):
"""
Client API operation adapter/wrapper
"""
if not settings.FEATURES.get('MILESTONES_APP', False):
return None
from milestones import api as milestones_api
return milestones_api.add_milestone(milestone_data)
开发者ID:adoosii,项目名称:edx-platform,代码行数:8,代码来源:milestones_helpers.py
示例13: test_get_milestones
def test_get_milestones(self):
""" Unit Test: test_get_milestones """
namespace = 'test_get_milestones'
api.add_milestone({
'display_name': 'Local Milestone 1',
'name': 'local_milestone_1',
'namespace': namespace,
'description': 'Local Milestone 1 Description'
})
api.add_milestone({
'display_name': 'Local Milestone 2',
'name': 'local_milestone_2',
'namespace': namespace,
'description': 'Local Milestone 2 Description'
})
with self.assertNumQueries(1):
milestones = api.get_milestones(namespace=namespace)
self.assertEqual(len(milestones), 2)
开发者ID:edx,项目名称:edx-milestones,代码行数:18,代码来源:test_api.py
示例14: test_fetch_milestone_courses_no_relationship_type
def test_fetch_milestone_courses_no_relationship_type(self):
""" Unit Test: test_fetch_milestone_courses_no_relationship_type"""
milestone1 = api.add_milestone({
'display_name': 'Test Milestone',
'name': 'test_milestone',
'namespace': unicode(self.test_course_key),
'description': 'Test Milestone Description',
})
api.add_course_milestone(self.test_course_key, 'fulfills', milestone1)
self.assertEqual(len(data.fetch_milestone_courses(milestone1)), 1)
开发者ID:GbalsaC,项目名称:bitnamiP,代码行数:10,代码来源:test_data.py
示例15: test_add_milestone
def test_add_milestone(self):
""" Unit Test: test_add_milestone"""
with self.assertNumQueries(2):
milestone = api.add_milestone({
'name': 'local_milestone',
'display_name': 'Local Milestone',
'namespace': six.text_type(self.test_course_key),
'description': 'Local Milestone Description'
})
self.assertGreater(milestone['id'], 0)
开发者ID:edx,项目名称:edx-milestones,代码行数:10,代码来源:test_api.py
示例16: _create_entrance_exam
def _create_entrance_exam(request, course_key, entrance_exam_minimum_score_pct=None):
"""
Internal workflow operation to create an entrance exam
"""
# Provide a default value for the minimum score percent if nothing specified
if entrance_exam_minimum_score_pct is None:
entrance_exam_minimum_score_pct = float(settings.ENTRANCE_EXAM_MIN_SCORE_PCT)
# Confirm the course exists
course = modulestore().get_course(course_key)
if course is None:
return HttpResponse(status=400)
# Create the entrance exam item (currently it's just a chapter)
payload = {
"category": "chapter",
"display_name": "Entrance Exam",
"parent_locator": unicode(course.location),
"is_entrance_exam": True,
"in_entrance_exam": True,
}
factory = RequestFactory()
internal_request = factory.post("/", json.dumps(payload), content_type="application/json")
internal_request.user = request.user
created_item = json.loads(create_item(internal_request).content)
# Set the entrance exam metadata flags for this course
# Reload the course so we don't overwrite the new child reference
course = modulestore().get_course(course_key)
metadata = {
"entrance_exam_enabled": True,
"entrance_exam_minimum_score_pct": entrance_exam_minimum_score_pct / 100,
"entrance_exam_id": created_item["locator"],
}
CourseMetadata.update_from_dict(metadata, course, request.user)
# Add an entrance exam milestone if one does not already exist
milestone_namespace = generate_milestone_namespace(NAMESPACE_CHOICES["ENTRANCE_EXAM"], course_key)
milestones = milestones_api.get_milestones(milestone_namespace)
if len(milestones):
milestone = milestones[0]
else:
description = "Autogenerated during {} entrance exam creation.".format(unicode(course.id))
milestone = milestones_api.add_milestone(
{"name": "Completed Course Entrance Exam", "namespace": milestone_namespace, "description": description}
)
relationship_types = milestones_api.get_milestone_relationship_types()
milestones_api.add_course_milestone(unicode(course.id), relationship_types["REQUIRES"], milestone)
milestones_api.add_course_content_milestone(
unicode(course.id), created_item["locator"], relationship_types["FULFILLS"], milestone
)
return HttpResponse(status=201)
开发者ID:geekmooc,项目名称:edx-platform,代码行数:53,代码来源:entrance_exam.py
示例17: setUp
def setUp(self):
"""
Milestones API Test Case scaffolding
"""
super(MilestonesApiTestCase, self).setUp()
self.test_milestone = api.add_milestone({
'name': 'test_milestone',
'display_name': 'Test Milestone',
'namespace': six.text_type(self.test_course_key),
'description': 'Test Milestone Description',
})
self.relationship_types = api.get_milestone_relationship_types()
开发者ID:edx,项目名称:edx-milestones,代码行数:12,代码来源:test_api.py
示例18: test_find_gating_milestones
def test_find_gating_milestones(self):
""" Test test_find_gating_milestones """
gating_api.add_prerequisite(self.course.id, self.seq1.location)
gating_api.set_required_content(self.course.id, self.seq2.location, self.seq1.location, 100)
milestone = milestones_api.add_milestone(self.generic_milestone)
milestones_api.add_course_content_milestone(self.course.id, self.seq1.location, 'fulfills', milestone)
self.assertEqual(len(gating_api.find_gating_milestones(self.course.id, self.seq1.location, 'fulfills')), 1)
self.assertEqual(len(gating_api.find_gating_milestones(self.course.id, self.seq1.location, 'requires')), 0)
self.assertEqual(len(gating_api.find_gating_milestones(self.course.id, self.seq2.location, 'fulfills')), 0)
self.assertEqual(len(gating_api.find_gating_milestones(self.course.id, self.seq2.location, 'requires')), 1)
开发者ID:10clouds,项目名称:edx-platform,代码行数:12,代码来源:test_api.py
示例19: test_get_required_content_with_anonymous_user
def test_get_required_content_with_anonymous_user(self):
course = CourseFactory()
required_content = milestones_helpers.get_required_content(course.id, AnonymousUser())
assert required_content == []
# NOTE (CCB): The initial version of anonymous courseware access is very simple. We avoid accidentally
# exposing locked content by simply avoiding anonymous access altogether for courses runs with milestones.
milestone = milestones_api.add_milestone({
'name': 'test',
'namespace': 'test',
})
milestones_helpers.add_course_milestone(str(course.id), 'requires', milestone)
with pytest.raises(InvalidUserException):
milestones_helpers.get_required_content(course.id, AnonymousUser())
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:15,代码来源:test_milestones_helpers.py
示例20: test_fetch_milestone_course_content_no_relationship_type
def test_fetch_milestone_course_content_no_relationship_type(self):
""" Unit Test: test_fetch_milestone_course_content_no_relationship_type"""
milestone1 = api.add_milestone({
'display_name': 'Test Milestone',
'name': 'test_milestone',
'namespace': six.text_type(self.test_course_key),
'description': 'Test Milestone Description',
})
api.add_course_content_milestone(
self.test_course_key,
self.test_content_key,
self.relationship_types['FULFILLS'],
milestone1
)
self.assertEqual(len(data.fetch_milestone_course_content(milestone1)), 1)
开发者ID:edx,项目名称:edx-milestones,代码行数:15,代码来源:test_data.py
注:本文中的milestones.api.add_milestone函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论