Skip to content

test: unit test for tasks module #149

Closed

Description

@SohamRatnaparkhi

Is your feature request related to a problem? Please describe.
This issue is in connection to issue #15
The current code-base does not have a test for tasks module.

This is a Python module that has scripts defining a Celery task named task__track_task_progress that is responsible for relaying a task run request to a remote TES (Task Execution Service) API, and then tracking the progress of the task.

Within the task, there is code for creating a database client, updating the state of the task to INITIALIZING, fetching the task log, and then tracking the task progress by continuously polling the remote TES API. The task state is updated in the database as the task progresses, and finally, once the task has finished, the document in the database is updated to reflect the final state and the output logs.

Describe the solution you'd like
The test will have following test:

  • mocks the DbDocumentConnector and tes.HTTPClient classes and the Flask app instance.
  • tests whether the update_task_state and get_document methods are called with the correct arguments
  • test whether the upsert_fields_in_root_object method is called with the correct root and arguments after the task has finished.
  • tests whether the get_task method of tes.HTTPClient is called with the correct arguments and whether the state of the task is updated correctly in the database.

Additional context
The tests will be added to test folder.

Activity

  1. uniqueg commented on Mar 18, 2023

    @uniqueg
    Member

    Thanks @SohamRatnaparkhi, please go ahead if you like :)

  2. uniqueg commented on Oct 22, 2026

    @uniqueg
    Member

    Thanks @SohamRatnaparkhi! The tests for the Celery task are now part of #207, which sets up the test suite the way all FOCA apps do (app test harness, mongomock plus a real MongoDB job). The PR for #207 will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions