Exemplo n.º 1
0
def test_mixer_cycle():
    mixer = Mixer()
    test = mixer.cycle(3).blend(Test)
    assert len(test) == 3
    assert test[0].__class__ == Test

    test = mixer.cycle(3).blend(Test, name=mixer.sequence('lama{0}'))
    assert test[2].name == 'lama2'
Exemplo n.º 2
0
    def test_mixer_cycle(self):
        mixer = Mixer()
        test = mixer.cycle(3).blend(Test)
        self.assertEqual(len(test), 3)
        self.assertTrue(type(test[0]), Test)

        test = mixer.cycle(3).blend(Test,
                                    name=mixer.sequence('lama{0}'))
        self.assertEqual(test[2].name, 'lama2')
Exemplo n.º 3
0
    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')
Exemplo n.º 4
0
    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,
                                         events=[])
        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)