本文整理汇总了Python中mock.Mock.start方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.start方法的具体用法?Python Mock.start怎么用?Python Mock.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.Mock
的用法示例。
在下文中一共展示了Mock.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__has_access_descriptor_staff_lock
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor_staff_lock(self):
"""
Tests that "visible_to_staff_only" overrides start date.
"""
mock_unit = Mock(user_partitions=[])
mock_unit._class_tags = {} # Needed for detached check in _has_access_descriptor
# No start date, staff lock on
mock_unit.visible_to_staff_only = True
self.verify_access(mock_unit, False)
# No start date, staff lock off.
mock_unit.visible_to_staff_only = False
self.verify_access(mock_unit, True)
# Start date in the past, staff lock on.
mock_unit.start = datetime.datetime.now(pytz.utc) - datetime.timedelta(days=1)
mock_unit.visible_to_staff_only = True
self.verify_access(mock_unit, False)
# Start date in the past, staff lock off.
mock_unit.visible_to_staff_only = False
self.verify_access(mock_unit, True)
# Start date in the future, staff lock on.
mock_unit.start = datetime.datetime.now(pytz.utc) + datetime.timedelta(days=1) # release date in the future
mock_unit.visible_to_staff_only = True
self.verify_access(mock_unit, False)
# Start date in the future, staff lock off.
mock_unit.visible_to_staff_only = False
self.verify_access(mock_unit, False)
示例2: default_args
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def default_args():
args = Mock()
args.conf_file = '.lamvery.yml'
args.follow = False
args.interval = 1
args.start = '-1h'
return args
示例3: test__has_access_descriptor_staff_lock
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor_staff_lock(self):
"""
Tests that "visible_to_staff_only" overrides start date.
"""
mock_unit = Mock()
mock_unit._class_tags = {} # Needed for detached check in _has_access_descriptor
def verify_access(student_should_have_access):
""" Verify the expected result from _has_access_descriptor """
self.assertEqual(
student_should_have_access,
access._has_access_descriptor(
self.anonymous_user, "load", mock_unit, course_key=self.course.course_key
),
)
# staff always has access
self.assertTrue(
access._has_access_descriptor(self.course_staff, "load", mock_unit, course_key=self.course.course_key)
)
# No start date, staff lock on
mock_unit.visible_to_staff_only = True
verify_access(False)
# No start date, staff lock off.
mock_unit.visible_to_staff_only = False
verify_access(True)
# Start date in the past, staff lock on.
mock_unit.start = datetime.datetime.now(pytz.utc) - datetime.timedelta(days=1)
mock_unit.visible_to_staff_only = True
verify_access(False)
# Start date in the past, staff lock off.
mock_unit.visible_to_staff_only = False
verify_access(True)
# Start date in the future, staff lock on.
mock_unit.start = datetime.datetime.now(pytz.utc) + datetime.timedelta(days=1) # release date in the future
mock_unit.visible_to_staff_only = True
verify_access(False)
# Start date in the future, staff lock off.
mock_unit.visible_to_staff_only = False
verify_access(False)
示例4: test__has_access_descriptor_beta_user
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor_beta_user(self):
mock_unit = Mock(user_partitions=[])
mock_unit._class_tags = {}
mock_unit.days_early_for_beta = 2
mock_unit.start = self.TOMORROW
mock_unit.visible_to_staff_only = False
self.assertTrue(bool(access._has_access_descriptor(
self.beta_user, 'load', mock_unit, course_key=self.course.id)))
示例5: test__has_access_descriptor
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor(self):
# TODO: override DISABLE_START_DATES and test the start date branch of the method
u = Mock()
d = Mock()
d.start = datetime.datetime.now(pytz.utc) - datetime.timedelta(days=1) # make sure the start time is in the past
# Always returns true because DISABLE_START_DATES is set in test.py
self.assertTrue(access._has_access_descriptor(u, d, 'load'))
self.assertRaises(ValueError, access._has_access_descriptor, u, d, 'not_load_or_staff')
示例6: test__has_access_descriptor_in_preview_mode
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor_in_preview_mode(self, start):
"""
Tests that descriptor has access in preview mode.
"""
mock_unit = Mock(user_partitions=[])
mock_unit._class_tags = {} # Needed for detached check in _has_access_descriptor
mock_unit.visible_to_staff_only = False
mock_unit.start = start
self.verify_access(mock_unit, True)
示例7: test__has_access_descriptor_when_not_in_preview_mode
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor_when_not_in_preview_mode(self):
"""
Tests that descriptor has no access when start date in future & without preview.
"""
mock_unit = Mock(user_partitions=[])
mock_unit._class_tags = {} # Needed for detached check in _has_access_descriptor
# No start date.
mock_unit.visible_to_staff_only = False
self.verify_access(mock_unit, True)
# Start date in the past.
mock_unit.start = datetime.datetime.now(pytz.utc) - datetime.timedelta(days=1)
self.verify_access(mock_unit, True)
# Start date in the future.
mock_unit.start = datetime.datetime.now(pytz.utc) + datetime.timedelta(days=1) # release date in the future
self.verify_access(mock_unit, False)
示例8: test__has_access_descriptor
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor(self):
# TODO: override DISABLE_START_DATES and test the start date branch of the method
u = Mock()
d = Mock()
d.start = time.gmtime(time.time() - 86400) # make sure the start time is in the past
# Always returns true because DISABLE_START_DATES is set in test.py
self.assertTrue(access._has_access_descriptor(u, d, "load"))
self.assertRaises(ValueError, access._has_access_descriptor, u, d, "not_load_or_staff")
示例9: test_index_iter_stop
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test_index_iter_stop():
os = OverlapSearcher("asdf")
segment = Mock()
segment.start = 11
try:
os.index_iter(segment, stop=10).next()
except ValueError:
assert True
else:
assert False
示例10: test__has_access_descriptor_staff_lock
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor_staff_lock(self, visible_to_staff_only, start, expected_error_type=None):
"""
Tests that "visible_to_staff_only" overrides start date.
"""
expected_access = expected_error_type is None
mock_unit = Mock(user_partitions=[])
mock_unit._class_tags = {} # Needed for detached check in _has_access_descriptor
mock_unit.visible_to_staff_only = visible_to_staff_only
mock_unit.start = start
self.verify_access(mock_unit, expected_access, expected_error_type)
示例11: test__has_access_descriptor_when_not_in_preview_mode
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor_when_not_in_preview_mode(self, start, expected_error_type):
"""
Tests that descriptor has no access when start date in future & without preview.
"""
expected_access = expected_error_type is None
mock_unit = Mock(user_partitions=[])
mock_unit._class_tags = {} # Needed for detached check in _has_access_descriptor
mock_unit.visible_to_staff_only = False
mock_unit.start = start
self.verify_access(mock_unit, expected_access, expected_error_type)
示例12: get_contest
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def get_contest():
contest = Mock()
contest.id = get_int()
contest.name = get_string()
start = get_int(2 ** 11)
duration = get_int(2 ** 8)
contest.start = make_datetime(start)
contest.stop = make_datetime(start + duration)
contest.score_precision = 2
contest.description = get_string()
return contest
示例13: test__has_access_descriptor_in_preview_mode
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test__has_access_descriptor_in_preview_mode(self, start):
"""
Tests that descriptor has access in preview mode.
"""
mock_unit = Mock(location=self.course.location, user_partitions=[])
mock_unit._class_tags = {} # Needed for detached check in _has_access_descriptor
mock_unit.visible_to_staff_only = False
mock_unit.start = self.DATES[start]
mock_unit.merged_group_access = {}
self.verify_access(mock_unit, True)
示例14: test___init__
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test___init__():
segs = []
for i in range(3):
seg = Mock()
seg.start = i * 3
seg.stop = i * 3 + 3
segs.append(seg)
sc = SegmentChain(segs)
assert sc.segments == segs
assert sc.segment_start == [0, 3, 6]
sc = SegmentChain()
assert sc.segments == sc.segment_start == []
示例15: test_must_start_container
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import start [as 别名]
def test_must_start_container(self):
self.container.is_created.return_value = True
container_mock = Mock()
self.mock_docker_client.containers.get.return_value = container_mock
container_mock.start = Mock()
self.container.start()
self.mock_docker_client.containers.get.assert_called_with(self.container.id)
container_mock.start.assert_called_with()