當前位置: 首頁>>代碼示例>>Python>>正文


Python mixer.cycle方法代碼示例

本文整理匯總了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))
        ) 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:21,代碼來源:test_admin.py

示例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) 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:18,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:18,代碼來源:test_state_changes.py

示例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) 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:18,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:18,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:19,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:21,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:20,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:20,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:23,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:23,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:26,代碼來源:test_state_changes.py

示例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') 
開發者ID:LCOGT,項目名稱:valhalla,代碼行數:26,代碼來源:test_state_changes.py

示例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 
開發者ID:fgmacedo,項目名稱:django-export-action,代碼行數:20,代碼來源:test_export_action.py

示例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] 
開發者ID:fgmacedo,項目名稱:django-export-action,代碼行數:20,代碼來源:test_export_action.py


注:本文中的mixer.backend.django.mixer.cycle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。