コード例 #1
0
    def test_instances_hit(self):
        [DeferIterationTestModel.objects.create() for i in range(25)]

        defer_iteration_with_finalize(
            DeferIterationTestModel.objects.all(),
            callback,
            finalize
        )

        self.process_task_queues()

        self.assertEqual(25, DeferIterationTestModel.objects.filter(touched=True).count())
        self.assertEqual(25, DeferIterationTestModel.objects.filter(finalized=True).count())
コード例 #2
0
    def test_passing_args_and_kwargs(self):
        [DeferIterationTestModel.objects.create() for i in range(25)]

        defer_iteration_with_finalize(
            DeferIterationTestModel.objects.all(),
            callback,
            finalize,
            touch=False  # kwarg to not touch the objects at all
        )

        self.process_task_queues()

        self.assertEqual(0, DeferIterationTestModel.objects.filter(touched=True).count())
コード例 #3
0
    def test_excluded_missed(self):
        [DeferIterationTestModel.objects.create(ignored=(i < 5)) for i in range(25)]

        defer_iteration_with_finalize(
            DeferIterationTestModel.objects.filter(ignored=False),
            callback,
            finalize
        )

        self.process_task_queues()

        self.assertEqual(5, DeferIterationTestModel.objects.filter(ignored=True).count())
        self.assertEqual(20, DeferIterationTestModel.objects.filter(touched=True).count())
        self.assertEqual(25, DeferIterationTestModel.objects.filter(finalized=True).count())
コード例 #4
0
ファイル: test_defer_iteration.py プロジェクト: vzts/djangae
    def test_instances_hit(self):
        [DeferIterationTestModel.objects.create() for i in range(25)]

        defer_iteration_with_finalize(DeferIterationTestModel.objects.all(),
                                      callback, finalize)

        self.process_task_queues()

        self.assertEqual(
            25,
            DeferIterationTestModel.objects.filter(touched=True).count())
        self.assertEqual(
            25,
            DeferIterationTestModel.objects.filter(finalized=True).count())
コード例 #5
0
    def test_passing_args_and_kwargs(self):
        [DeferIterationTestModel.objects.create() for i in range(25)]

        defer_iteration_with_finalize(
            DeferIterationTestModel.objects.all(),
            callback,
            finalize,
            touch=False,  # kwarg to not touch the objects at all
            _shards=_SHARD_COUNT)

        self.process_task_queues()

        self.assertEqual(
            0,
            DeferIterationTestModel.objects.filter(touched=True).count())
コード例 #6
0
    def test_shard_continue_on_error(self):
        [DeferIterationTestModel.objects.create(pk=i + 1) for i in range(25)]

        global sporadic_error_counter
        sporadic_error_counter = 0

        defer_iteration_with_finalize(
            DeferIterationTestModel.objects.all(),
            sporadic_error,
            finalize
        )

        self.process_task_queues()

        self.assertEqual(25, DeferIterationTestModel.objects.filter(touched=True).count())
        self.assertEqual(25, DeferIterationTestModel.objects.filter(finalized=True).count())
コード例 #7
0
ファイル: test_defer_iteration.py プロジェクト: vzts/djangae
    def test_shard_continue_on_error(self):
        [DeferIterationTestModel.objects.create(pk=i + 1) for i in range(25)]

        global sporadic_error_counter
        sporadic_error_counter = 0

        defer_iteration_with_finalize(DeferIterationTestModel.objects.all(),
                                      sporadic_error, finalize)

        self.process_task_queues()

        self.assertEqual(
            25,
            DeferIterationTestModel.objects.filter(touched=True).count())
        self.assertEqual(
            25,
            DeferIterationTestModel.objects.filter(finalized=True).count())
コード例 #8
0
ファイル: test_defer_iteration.py プロジェクト: vzts/djangae
    def test_excluded_missed(self):
        [
            DeferIterationTestModel.objects.create(ignored=(i < 5))
            for i in range(25)
        ]

        defer_iteration_with_finalize(
            DeferIterationTestModel.objects.filter(ignored=False), callback,
            finalize)

        self.process_task_queues()

        self.assertEqual(
            5,
            DeferIterationTestModel.objects.filter(ignored=True).count())
        self.assertEqual(
            20,
            DeferIterationTestModel.objects.filter(touched=True).count())
        self.assertEqual(
            25,
            DeferIterationTestModel.objects.filter(finalized=True).count())