本文整理汇总了Python中mixer.backend.django.mixer.cycle方法的典型用法代码示例。如果您正苦于以下问题:Python mixer.cycle方法的具体用法?Python mixer.cycle怎么用?Python mixer.cycle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mixer.backend.django.mixer
的用法示例。
在下文中一共展示了mixer.cycle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def setUp(self):
self.semester = mixer.blend(Semester)
self.user = mixer.blend(User)
self.admin_user = User.objects.create_superuser('admin', '[email protected]', 'password')
self.client.force_login(self.admin_user)
self.call = mixer.blend(
Call, semester=self.semester,
deadline=timezone.now() + timedelta(days=7),
opens=timezone.now(),
proposal_type=Call.SCI_PROPOSAL
)
mixer.blend(Instrument, call=self.call)
self.apps = mixer.cycle(3).blend(
ScienceApplication,
status=ScienceApplication.SUBMITTED,
submitter=self.user,
call=self.call,
tac_rank=(x for x in range(3))
)
示例2: test_request_state_pond_state_initial_state_pending
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_request_state_pond_state_initial_state_pending(self):
request = dmixer.blend(Request, state='PENDING')
fail_count = request.fail_count
now = timezone.now()
molecules = mixer.cycle(4).blend(PondMolecule, completed=False, failed=False, event=[])
pond_blocks = [mixer.blend(PondBlock, molecules=molecules, canceled=False, start=now - timedelta(minutes=30),
end=now + timedelta(minutes=30))._to_dict(),
mixer.blend(PondBlock, molecules=molecules)._to_dict()]
state_changed = update_request_state(request, pond_blocks, False)
request.refresh_from_db()
self.assertFalse(state_changed)
self.assertEqual(request.state, 'PENDING')
self.assertEqual(fail_count, request.fail_count)
示例3: test_request_state_pond_state_failed_but_threshold_complete_2
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_request_state_pond_state_failed_but_threshold_complete_2(self):
request = dmixer.blend(Request, state='PENDING', acceptability_threshold=70.0)
now = timezone.now()
molecules = mixer.cycle(4).blend(PondMolecule, completed=False, failed=True, event=[{'completedExposures': 0},],
exp_time=100, exp_cnt=1)
molecules.append(mixer.blend(PondMolecule, completed=True, failed=False, event=[{'completedExposures': 10,}],
exp_time=100, exp_cnt=10))
pond_blocks = [mixer.blend(PondBlock, molecules=molecules, start=now - timedelta(minutes=30), end=now + timedelta(minutes=30))._to_dict(),
mixer.blend(PondBlock, molecules=molecules)._to_dict()]
state_changed = update_request_state(request, pond_blocks, False)
request.refresh_from_db()
self.assertTrue(state_changed)
self.assertEqual(request.state, 'COMPLETED')
示例4: test_request_state_pond_state_failed_and_threshold_failed
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_request_state_pond_state_failed_and_threshold_failed(self):
request = dmixer.blend(Request, state='PENDING', acceptability_threshold=95.0)
fail_count = request.fail_count
now = timezone.now()
molecules = mixer.cycle(4).blend(PondMolecule, completed=False, failed=True, event=[{'completedExposures': 9},],
exp_time=100, exp_cnt=10)
pond_blocks = [mixer.blend(PondBlock, molecules=molecules, start=now - timedelta(minutes=30), end=now + timedelta(minutes=30))._to_dict(),
mixer.blend(PondBlock, molecules=molecules)._to_dict()]
state_changed = update_request_state(request, pond_blocks, False)
request.refresh_from_db()
self.assertTrue(state_changed)
self.assertEqual(request.state, 'PENDING')
self.assertEqual(fail_count + 1, request.fail_count)
示例5: test_many_requests_expire_after_last_window
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_many_requests_expire_after_last_window(self, modify_mock):
now = timezone.now()
dmixer.cycle(3).blend(Window, request=(r for r in self.requests), start=now-timedelta(days=2), end=now-timedelta(days=1))
molecules1 = mixer.cycle(3).blend(PondMolecule, completed=False, failed=False, request_num=self.requests[0].id, tracking_num=self.ur.id, event=[])
molecules2 = mixer.cycle(3).blend(PondMolecule, completed=False, failed=False, request_num=self.requests[1].id, tracking_num=self.ur.id, event=[])
molecules3 = mixer.cycle(3).blend(PondMolecule, completed=False, failed=False, request_num=self.requests[2].id, tracking_num=self.ur.id, event=[])
pond_blocks = mixer.cycle(3).blend(PondBlock, molecules=(m for m in [molecules1, molecules2, molecules3]), start=now - timedelta(minutes=30), end=now - timedelta(minutes=20))
pond_blocks = [pb._to_dict() for pb in pond_blocks]
update_request_states_from_pond_blocks(pond_blocks)
for req in self.requests:
req.refresh_from_db()
self.assertEqual(req.state, 'WINDOW_EXPIRED')
self.ur.refresh_from_db()
self.assertEqual(self.ur.state, 'WINDOW_EXPIRED')
示例6: test_many_requests_complete_and_expired
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_many_requests_complete_and_expired(self, modify_mock):
now = timezone.now()
dmixer.cycle(3).blend(Window, request=(r for r in self.requests), start=now-timedelta(days=2), end=now-timedelta(days=1))
molecules1 = mixer.cycle(3).blend(PondMolecule, completed=True, failed=False, request_num=self.requests[0].id, tracking_num=self.ur.id, event=[])
molecules2 = mixer.cycle(3).blend(PondMolecule, completed=False, failed=False, request_num=self.requests[1].id, tracking_num=self.ur.id, event=[])
molecules3 = mixer.cycle(3).blend(PondMolecule, completed=False, failed=False, request_num=self.requests[2].id, tracking_num=self.ur.id, event=[])
pond_blocks = mixer.cycle(3).blend(PondBlock, molecules=(m for m in [molecules1, molecules2, molecules3]), start=now - timedelta(minutes=30), end=now - timedelta(minutes=20))
pond_blocks = [pb._to_dict() for pb in pond_blocks]
update_request_states_from_pond_blocks(pond_blocks)
request_states = ['COMPLETED', 'WINDOW_EXPIRED', 'WINDOW_EXPIRED']
for i, req in enumerate(self.requests):
req.refresh_from_db()
self.assertEqual(req.state, request_states[i])
self.ur.refresh_from_db()
self.assertEqual(self.ur.state, 'COMPLETED')
示例7: test_many_requests_window_expired_and_failed
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_many_requests_window_expired_and_failed(self, modify_mock):
now = timezone.now()
self.requests[0].state = 'WINDOW_EXPIRED'
self.requests[0].save()
dmixer.cycle(3).blend(Window, request=(r for r in self.requests), start=now-timedelta(days=2), end=now+timedelta(days=1))
molecules1 = mixer.cycle(3).blend(PondMolecule, completed=False, failed=False, request_num=self.requests[0].id, tracking_num=self.ur.id, event=[])
molecules2 = mixer.cycle(3).blend(PondMolecule, completed=False, failed=True, request_num=self.requests[1].id, tracking_num=self.ur.id, event=[])
molecules3 = mixer.cycle(3).blend(PondMolecule, completed=False, failed=True, request_num=self.requests[2].id, tracking_num=self.ur.id, event=[])
pond_blocks = mixer.cycle(3).blend(PondBlock, molecules=(m for m in [molecules1, molecules2, molecules3]), start=now - timedelta(minutes=30), end=now - timedelta(minutes=20))
pond_blocks = [pb._to_dict() for pb in pond_blocks]
update_request_states_from_pond_blocks(pond_blocks)
request_states = ['WINDOW_EXPIRED', 'PENDING', 'PENDING']
for i, req in enumerate(self.requests):
req.refresh_from_db()
self.assertEqual(req.state, request_states[i])
self.ur.refresh_from_db()
self.assertEqual(self.ur.state, 'PENDING')
示例8: test_many_requests_complete_and_complete
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_many_requests_complete_and_complete(self, modify_mock):
now = timezone.now()
self.requests[0].state = 'COMPLETED'
self.requests[0].save()
self.requests[1].state = 'COMPLETED'
self.requests[1].save()
dmixer.cycle(3).blend(Window, request=(r for r in self.requests), start=now-timedelta(days=2), end=now+timedelta(days=1))
molecules3 = mixer.cycle(3).blend(PondMolecule, completed=True, failed=False, request_num=self.requests[2].id, tracking_num=self.ur.id)
pond_blocks = [mixer.blend(PondBlock, molecules=molecules3, start=now - timedelta(minutes=30), end=now - timedelta(minutes=20))._to_dict()]
update_request_states_from_pond_blocks(pond_blocks)
request_states = ['COMPLETED', 'COMPLETED', 'COMPLETED']
for i, req in enumerate(self.requests):
req.refresh_from_db()
self.assertEqual(req.state, request_states[i])
self.ur.refresh_from_db()
self.assertEqual(self.ur.state, 'COMPLETED')
示例9: test_many_requests_complete_and_window_expired
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_many_requests_complete_and_window_expired(self, modify_mock):
now = timezone.now()
self.requests[0].state = 'COMPLETED'
self.requests[0].save()
self.requests[1].state = 'COMPLETED'
self.requests[1].save()
dmixer.cycle(3).blend(Window, request=(r for r in self.requests), start=now-timedelta(days=2), end=now-timedelta(days=1))
molecules3 = mixer.cycle(3).blend(PondMolecule, completed=False, failed=True, request_num=self.requests[2].id, tracking_num=self.ur.id, event=[])
pond_blocks = [mixer.blend(PondBlock, molecules=molecules3, start=now - timedelta(minutes=30), end=now - timedelta(minutes=20))._to_dict()]
update_request_states_from_pond_blocks(pond_blocks)
request_states = ['COMPLETED', 'COMPLETED', 'WINDOW_EXPIRED']
for i, req in enumerate(self.requests):
req.refresh_from_db()
self.assertEqual(req.state, request_states[i])
self.ur.refresh_from_db()
self.assertEqual(self.ur.state, 'COMPLETED')
示例10: test_many_requests_window_expired_to_completed
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_many_requests_window_expired_to_completed(self, modify_mock):
now = timezone.now()
for req in self.requests:
req.state = 'WINDOW_EXPIRED'
req.save()
self.ur.state = 'WINDOW_EXPIRED'
self.ur.save()
dmixer.cycle(3).blend(Window, request=(r for r in self.requests), start=now-timedelta(days=2), end=now-timedelta(days=1))
molecules3 = mixer.cycle(3).blend(PondMolecule, completed=True, failed=False, request_num=self.requests[2].id, tracking_num=self.ur.id)
pond_blocks = [mixer.blend(PondBlock, molecules=molecules3, start=now - timedelta(minutes=30), end=now - timedelta(minutes=20))._to_dict()]
update_request_states_from_pond_blocks(pond_blocks)
request_states = ['WINDOW_EXPIRED', 'WINDOW_EXPIRED', 'COMPLETED']
for i, req in enumerate(self.requests):
req.refresh_from_db()
self.assertEqual(req.state, request_states[i])
self.ur.refresh_from_db()
self.assertEqual(self.ur.state, 'COMPLETED')
示例11: test_many_requests_canceled_to_completed
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_many_requests_canceled_to_completed(self, modify_mock):
now = timezone.now()
for req in self.requests:
req.state = 'CANCELED'
req.save()
self.ur.state = 'CANCELED'
self.ur.save()
dmixer.cycle(3).blend(Window, request=(r for r in self.requests), start=now-timedelta(days=2), end=now-timedelta(days=1))
molecules3 = mixer.cycle(3).blend(PondMolecule, completed=True, failed=False, request_num=self.requests[2].id, tracking_num=self.ur.id)
pond_blocks = [mixer.blend(PondBlock, molecules=molecules3, start=now - timedelta(minutes=30), end=now - timedelta(minutes=20))._to_dict()]
update_request_states_from_pond_blocks(pond_blocks)
request_states = ['CANCELED', 'CANCELED', 'COMPLETED']
for i, req in enumerate(self.requests):
req.refresh_from_db()
self.assertEqual(req.state, request_states[i])
self.ur.refresh_from_db()
self.assertEqual(self.ur.state, 'COMPLETED')
示例12: test_oneof_requests_window_expired_to_completed
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_oneof_requests_window_expired_to_completed(self, modify_mock):
now = timezone.now()
self.ur.operator = 'ONEOF'
self.ur.save()
for req in self.requests:
req.state = 'WINDOW_EXPIRED'
req.save()
self.ur.state = 'WINDOW_EXPIRED'
self.ur.save()
dmixer.cycle(3).blend(Window, request=(r for r in self.requests), start=now - timedelta(days=2),
end=(e for e in [now - timedelta(days=1), now - timedelta(days=1), now + timedelta(days=1)]))
molecules3 = mixer.cycle(3).blend(PondMolecule, completed=True, failed=False, request_num=self.requests[2].id, tracking_num=self.ur.id)
pond_blocks = [mixer.blend(PondBlock, molecules=molecules3, start=now - timedelta(minutes=30), end=now - timedelta(minutes=20))._to_dict()]
update_request_states_from_pond_blocks(pond_blocks)
request_states = ['WINDOW_EXPIRED', 'WINDOW_EXPIRED', 'COMPLETED']
for i, req in enumerate(self.requests):
req.refresh_from_db()
self.assertEqual(req.state, request_states[i])
self.ur.refresh_from_db()
self.assertEqual(self.ur.state, 'COMPLETED')
示例13: test_oneof_requests_canceled_to_completed
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_oneof_requests_canceled_to_completed(self, modify_mock):
now = timezone.now()
self.ur.operator = 'ONEOF'
self.ur.save()
for req in self.requests:
req.state = 'CANCELED'
req.save()
self.ur.state = 'CANCELED'
self.ur.save()
dmixer.cycle(3).blend(Window, request=(r for r in self.requests), start=now - timedelta(days=2),
end=(e for e in [now - timedelta(days=1), now - timedelta(days=1), now + timedelta(days=1)]))
molecules3 = mixer.cycle(3).blend(PondMolecule, completed=True, failed=False, request_num=self.requests[2].id, tracking_num=self.ur.id)
pond_blocks = [mixer.blend(PondBlock, molecules=molecules3, start=now - timedelta(minutes=30), end=now - timedelta(minutes=20))._to_dict()]
update_request_states_from_pond_blocks(pond_blocks)
request_states = ['CANCELED', 'CANCELED', 'COMPLETED']
for i, req in enumerate(self.requests):
req.refresh_from_db()
self.assertEqual(req.state, request_states[i])
self.ur.refresh_from_db()
self.assertEqual(self.ur.state, 'COMPLETED')
示例14: test_admin_action_should_redirect_to_export_view
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_admin_action_should_redirect_to_export_view(admin_client):
objects = mixer.cycle(3).blend(Publication)
ids = [repr(obj.pk) for obj in objects]
data = {
"action": "export_selected_objects",
"_selected_action": ids,
}
url = reverse('admin:tests_publication_changelist')
response = admin_client.post(url, data=data)
expected_url = "{}?ct={ct}&ids={ids}".format(
reverse('export_action:export'),
ct=ContentType.objects.get_for_model(Publication).pk,
ids=','.join(ids)
)
assert response.status_code == 302
assert response.url == expected_url
示例15: test_admin_action_should_redirect_to_export_view_without_ids_for_large_queries
# 需要导入模块: from mixer.backend.django import mixer [as 别名]
# 或者: from mixer.backend.django.mixer import cycle [as 别名]
def test_admin_action_should_redirect_to_export_view_without_ids_for_large_queries(admin_client):
objects = mixer.cycle(1001).blend(Publication)
ids = [obj.pk for obj in objects[:50]]
data = {
"action": "export_selected_objects",
"_selected_action": ids,
"select_across": ids,
}
url = reverse('admin:tests_publication_changelist')
response = admin_client.post(url, data=data)
assert response.status_code == 302
assert 'session_key' in response.url
session_key = response.url[response.url.index('session_key=')+len('session_key='):]
session_ids = admin_client.session[session_key]
assert session_ids == [obj.pk for obj in objects]