Пример #1
0
    def test_mark_result_unchanged(self, send_update):
        send_update.side_effect = async_noop
        workflow = Workflow.create_and_init()
        wf_module = workflow.tabs.first().wf_modules.create(
            order=0, slug="step-1", is_busy=True, fetch_error="previous error"
        )
        now = timezone.datetime(2019, 10, 22, 12, 22, tzinfo=timezone.utc)

        self.run_with_async_db(save.mark_result_unchanged(workflow.id, wf_module, now))
        self.assertEqual(wf_module.stored_objects.count(), 0)

        self.assertEqual(wf_module.fetch_error, "previous error")
        self.assertEqual(wf_module.is_busy, False)
        self.assertEqual(wf_module.last_update_check, now)
        wf_module.refresh_from_db()
        self.assertEqual(wf_module.fetch_error, "previous error")
        self.assertEqual(wf_module.is_busy, False)
        self.assertEqual(wf_module.last_update_check, now)

        send_update.assert_called_with(
            workflow.id,
            clientside.Update(
                steps={
                    wf_module.id: clientside.StepUpdate(
                        is_busy=False, last_fetched_at=now
                    )
                }
            ),
        )
Пример #2
0
    def test_mark_result_unchanged(self, send_delta):
        send_delta.side_effect = async_noop
        workflow = Workflow.create_and_init()
        wf_module = workflow.tabs.first().wf_modules.create(
            order=0, slug="step-1", is_busy=True, fetch_error="previous error")
        now = timezone.datetime(2019, 10, 22, 12, 22, tzinfo=timezone.utc)

        self.run_with_async_db(
            save.mark_result_unchanged(workflow.id, wf_module, now))
        self.assertEqual(wf_module.stored_objects.count(), 0)

        self.assertEqual(wf_module.fetch_error, "previous error")
        self.assertEqual(wf_module.is_busy, False)
        self.assertEqual(wf_module.last_update_check, now)
        wf_module.refresh_from_db()
        self.assertEqual(wf_module.fetch_error, "previous error")
        self.assertEqual(wf_module.is_busy, False)
        self.assertEqual(wf_module.last_update_check, now)

        send_delta.assert_called_with(
            workflow.id,
            {
                "updateWfModules": {
                    str(wf_module.id): {
                        "is_busy": False,
                        "fetch_error": "previous error",
                        "last_update_check": "2019-10-22T12:22:00Z",
                    }
                }
            },
        )
Пример #3
0
    def test_mark_result_unchanged(self, send_update):
        send_update.side_effect = async_noop
        workflow = Workflow.create_and_init()
        step = workflow.tabs.first().steps.create(
            order=0,
            slug="step-1",
            is_busy=True,
            fetch_errors=[RenderError(I18nMessage("foo", {}, "module"))],
        )
        now = datetime.datetime(2019, 10, 22, 12, 22)

        self.run_with_async_db(
            save.mark_result_unchanged(workflow.id, step, now))
        self.assertEqual(step.stored_objects.count(), 0)

        self.assertEqual(step.fetch_errors,
                         [RenderError(I18nMessage("foo", {}, "module"))])
        self.assertEqual(step.is_busy, False)
        self.assertEqual(step.last_update_check, now)
        step.refresh_from_db()
        self.assertEqual(step.fetch_errors,
                         [RenderError(I18nMessage("foo", {}, "module"))])
        self.assertEqual(step.is_busy, False)
        self.assertEqual(step.last_update_check, now)

        send_update.assert_called_with(
            workflow.id,
            clientside.Update(steps={
                step.id:
                clientside.StepUpdate(is_busy=False, last_fetched_at=now)
            }),
        )