Exemple #1
0
def test_parse_activity():
    code = """account.invoice {
        draft {
        }
    }"""
    result = workflow_parser.parse(code)
    # pp(result)
    assert result == ("workflow", "account.invoice", [], [("activity", "draft", [], [])])
Exemple #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")])])
Exemple #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")], [])],
    )
Exemple #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", [], [])],
    )
Exemple #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)])],
    )
Exemple #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")]),
        ],
    )
Exemple #7
0
def test_empty_workflow():
    code = "account.invoice {}"
    result = workflow_parser.parse(code)
    assert result == ("workflow", "account.invoice", [], [])
Exemple #8
0
def test_workflow_with_arguments():
    code = "account.invoice(id: 'wkf') {}"
    result = workflow_parser.parse(code)
    assert result == ("workflow", "account.invoice", [("id", "wkf")], [])
def get_ast(code):
    tree = workflow_parser.parse(code)
    return tree_to_ast(tree)