Esempio n. 1
0
def test_parse_activity():
    code = """account.invoice {
        draft {
        }
    }"""
    result = workflow_parser.parse(code)
    # pp(result)
    assert result == ("workflow", "account.invoice", [], [("activity", "draft", [], [])])
Esempio n. 2
0
def test_parse_transitions_with_meta_and_parameters():
    code = """
    account.invoice {
        draft -> open {
            condition: 'True'
        }
    }
    """

    result = workflow_parser.parse(code)

    assert result == ("workflow", "account.invoice", [], [("transition", "draft", "open", [], [("condition", "True")])])
Esempio n. 3
0
def test_parse_transitions_with_meta():
    code = """
    account.invoice {
        draft -> open (id: 'draft_to_open')
    }
    """

    result = workflow_parser.parse(code)

    assert result == (
        "workflow",
        "account.invoice",
        [],
        [("transition", "draft", "open", [("id", "draft_to_open")], [])],
    )
Esempio n. 4
0
def test_parse_transitions():
    code = """
    account.invoice {
        draft -> open
        open -> closed
    }
    """
    result = workflow_parser.parse(code)

    assert result == (
        "workflow",
        "account.invoice",
        [],
        [("transition", "draft", "open", [], []), ("transition", "open", "closed", [], [])],
    )
Esempio n. 5
0
def test_parse_activity_and_parameters():
    code = """
    account.invoice {
        draft {
            start: True,
            stop: False
        }
    }
    """
    result = workflow_parser.parse(code)
    assert result == (
        "workflow",
        "account.invoice",
        [],
        [("activity", "draft", [], [("start", True), ("stop", False)])],
    )
Esempio n. 6
0
def test_parse_full():
    code = """
    account.invoice(id: 'wkf') {
        draft(id: 'act_draft') {
            start: True
        }
        draft -> open (id: 'draft_to_open') {
            signal: 'no_signal'
        }
    }
    """

    result = workflow_parser.parse(code)

    assert result == (
        "workflow",
        "account.invoice",
        [("id", "wkf")],
        [
            ("activity", "draft", [("id", "act_draft")], [("start", True)]),
            ("transition", "draft", "open", [("id", "draft_to_open")], [("signal", "no_signal")]),
        ],
    )
Esempio n. 7
0
def test_empty_workflow():
    code = "account.invoice {}"
    result = workflow_parser.parse(code)
    assert result == ("workflow", "account.invoice", [], [])
Esempio n. 8
0
def test_workflow_with_arguments():
    code = "account.invoice(id: 'wkf') {}"
    result = workflow_parser.parse(code)
    assert result == ("workflow", "account.invoice", [("id", "wkf")], [])
Esempio n. 9
0
def get_ast(code):
    tree = workflow_parser.parse(code)
    return tree_to_ast(tree)