Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(python): add updateProgress method in job class(#1830)
- Loading branch information
1 parent
182b4bb
commit e1e1aa2
Showing
7 changed files
with
79 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/bash | ||
redis-cli flushall | ||
python3 -m unittest -v tests.job_tests | ||
python3 -m unittest -v tests.queue_tests | ||
python3 -m unittest -v tests.worker_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Tests for job class. | ||
https://bbc.github.io/cloudfit-public-docs/asyncio/testing.html | ||
""" | ||
|
||
import unittest | ||
|
||
from bullmq import Queue, Job | ||
|
||
queueName = "__bullmq_test_queue__" | ||
|
||
class TestJob(unittest.IsolatedAsyncioTestCase): | ||
|
||
async def asyncSetUp(self): | ||
print("Setting up test queue") | ||
# Delete test queue | ||
queue = Queue(queueName) | ||
await queue.pause() | ||
await queue.obliterate() | ||
await queue.close() | ||
|
||
async def test_set_and_get_progress_as_number(self): | ||
queue = Queue(queueName) | ||
job = await queue.add("test-job", {"foo": "bar"}, {}) | ||
await job.updateProgress(42) | ||
stored_job = await Job.fromId(queue, job.id) | ||
self.assertEqual(stored_job.progress, 42) | ||
|
||
await queue.close() | ||
|
||
async def test_set_and_get_progress_as_object(self): | ||
queue = Queue(queueName) | ||
job = await queue.add("test-job", {"foo": "bar"}, {}) | ||
await job.updateProgress({"total": 120, "completed": 40}) | ||
stored_job = await Job.fromId(queue, job.id) | ||
self.assertEqual(stored_job.progress, {"total": 120, "completed": 40}) | ||
|
||
await queue.close() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |