Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing tools #3

Closed
ewjoachim opened this issue Feb 27, 2019 · 1 comment · Fixed by #22
Closed

Testing tools #3

ewjoachim opened this issue Feb 27, 2019 · 1 comment · Fixed by #22
Assignees
Milestone

Comments

@ewjoachim
Copy link
Member

ewjoachim commented Feb 27, 2019

For Cabbage to be used in a real codebase, we'll need a few tools that will make testability easier:

  • A pluggable in-memory list of created tasks
  • A way to launch these task synchronously
  • A way to launch a single task

I'm thinking something along the lines of:

from cabbage.testing import TestTaskManager
tm = TestTaskManager()

something = []

@tm.task(queue="yay")
def t(task_run, a):
    something.append(a)

t.defer(a=1)

# A pluggable in-memory list of created tasks
assert tm.scheduled == [{"name": "t", "args": {"a": 1}]

# A way to launch these task synchronously
tm.run_scheduled()

assert something == [1]

# A way to launch a single task
t.run(a=2)

assert something == [1, 2]

(For now, no idea how we'd substitute the TaskManager with the TestTaskManager in a real case, but we can think of something)

@ewjoachim ewjoachim added enhancement Issue contains: Some SQL 🐘 This features require changing the SQL model and removed Issue contains: Some SQL 🐘 This features require changing the SQL model labels Feb 28, 2019
@sdispater sdispater self-assigned this Apr 5, 2019
@ewjoachim
Copy link
Member Author

A way to launch a single task

That's being done in #19 ✔️

@ewjoachim ewjoachim self-assigned this Apr 21, 2019
@ewjoachim ewjoachim added this to the 1.0 milestone Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants