Source

juggler / testing / handlers / test_inbox.py

import pytest
from juggler import model
from juggler.model import states as s
from juggler.handlers import inbox

from testing import with_quick_change_timeout


@with_quick_change_timeout
def test_inbox_simple_validate(db):
    #XXX: test a invalid case
    order = model.Order(_id='order', status=s.received)
    db.save_doc(order)
    inbox.order_validate(db)
    db.refresh(order)
    assert order.status == s.valid


@with_quick_change_timeout
def test_valid_order_simple_ready(db):
    order = model.Order(status=s.valid)
    db.save_doc(order)
    inbox.valid_order_prepare(db)
    db.refresh(order)
    assert order.status == s.ready


@with_quick_change_timeout
@pytest.mark.parametrize(('axis', 'specs'), [
    (None, [{}]),
    ({'test': ['a', 'b']}, [
        {'test': 'a'},
        {'test':'b'}
    ]),
], ids=['nospec', 'somespec'])
def test_ready_order_generate_tasks(db, axis, specs):
    order = model.Order(status='ready', axis=axis)
    db.save_doc(order)
    inbox.ready_order_generate_tasks(db)
    db.refresh(order)
    assert order.status == 'building'

    items = db._.bulk_save.call_args[0][0]
    saved_order = items.pop(0)

    assert saved_order._doc == order._doc
    for task, spec in zip(items, specs):

        assert task.spec == spec
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.