Skip to content

Commit

Permalink
Update task status handling in tests and release process
Browse files Browse the repository at this point in the history
Updated the RQTaskQueueService test to initialize a task in a 'started' status and assert its properties get reset to 'idle'. Additionally, revised the release process instructions to incorporate 'commit' and 'bumpversion' commands, and clarified the steps to create a new release from a tag on GitHub.
  • Loading branch information
guglielmo committed Jul 24, 2024
1 parent 6e9f3d2 commit b4c2ebf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
7 changes: 4 additions & 3 deletions docs/howtos/dev_publish_changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ Each new version has a tag, and pushing to the main branch triggers linting and

.. code-block:: bash
bump
git commit -m "-- your changelog message --"
bumpversion patch
git push
git push --tags
Create a new release from a tag, manually specifying the previous release (for the changelog).
Each new release builds and publishes to pypi.org using poetry.
Create a new release from a tag, on github.com, https://github.com/openpolis/django-eztaskmanager/releases.
Manually specifying the previous release (for the changelog). Each new release builds and publishes to pypi.org using poetry.
To update the documentation, just push to the repository.
https://readthedocs.io is automatically synchronized with the GitHub repository.
After a few minutes, the changes are collected by the site, which then builds and publishes the latest version.
Expand Down
16 changes: 9 additions & 7 deletions eztaskmanager/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,14 @@ def test_remove_non_existing_job(self, mock_fetch_job_with_next_time, mock_get_s
# Create the instance of the RQTaskQueueService
service = RQTaskQueueService()

# Create a mock Task instance
# Create a mock Task instance in Started status
mock_task = MagicMock()
mock_task.scheduled_job_id = None
mock_task.cached_next_ride = None
mock_task.status = Task.STATUS_SCHEDULED
mock_task.scheduled_job_id = 'job-id'
mock_task.cached_next_ride = (datetime.now() + timedelta(days=5)).strftime("%Y-%m-%d %H:%M:%S")
mock_task.status = Task.STATUS_STARTED

# mock the return value of fetch_job_with_next_time
# no job is found (there's some sort of condition)
mock_fetch_job_with_next_time.return_value = (None, None)

# Call the method
Expand All @@ -253,11 +254,12 @@ def test_remove_non_existing_job(self, mock_fetch_job_with_next_time, mock_get_s
# Assert scheduler.cancel was not called
service.scheduler.cancel.assert_not_called()

# Assert the task attributes were not updated
# Assert the task attributes were reset
# The task status is now Idle
assert not mock_task.scheduled_job_id
assert not mock_task.cached_next_ride
assert not mock_task.status == Task.STATUS_IDLE
mock_task.save.assert_not_called()
assert mock_task.status == Task.STATUS_IDLE
mock_task.save.assert_called()

@patch('django_rq.get_scheduler', return_value=MagicMock())
def test_fetch_job_with_next_time_job_exists(self, mock_get_scheduler):
Expand Down

0 comments on commit b4c2ebf

Please sign in to comment.