Ejemplo n.º 1
0
def test_run():
    event = get_initialized_test_event()
    step = Step(actions=[AddOrderLogEntry({
        "order": {"variable": "order"},
        "message": {"constant": "It Works."},
        "message_identifier": {"constant": "test_run"},
    })], next=StepNext.STOP)
    script = Script(event_identifier=event.identifier, name="Test Script")
    script.set_steps([step])
    script.save()
    event.run()
    # The script is disabled by default, of course it won't run
    assert not event.variable_values["order"].log_entries.filter(identifier="test_run").exists()

    # Let's try that again.
    script.enabled = True
    script.save()
    event.run()
    assert event.variable_values["order"].log_entries.filter(identifier="test_run").exists()
    script.delete()
Ejemplo n.º 2
0
def test_load_save():
    sc = Script(event_identifier=TestEvent.identifier, name="Test Script")
    assert force_text(sc) == "Test Script"
    sc.set_serialized_steps(TEST_STEP_DATA)
    sc.save()
    sc = Script.objects.get(pk=sc.pk)

    first_step = sc.get_steps()[0]
    first_step_data = TEST_STEP_DATA[0]
    step_from_data = Step.unserialize(first_step_data)
    data_from_step = first_step.serialize()

    assert data_from_step == first_step_data
    assert first_step == step_from_data
Ejemplo n.º 3
0
def test_load_save():
    sc = Script(event_identifier=TestEvent.identifier, name="Test Script")
    assert force_text(sc) == "Test Script"
    sc.set_serialized_steps(TEST_STEP_DATA)
    sc.save()
    sc = Script.objects.get(pk=sc.pk)

    first_step = sc.get_steps()[0]
    first_step_data = TEST_STEP_DATA[0]
    step_from_data = Step.unserialize(first_step_data)
    data_from_step = first_step.serialize()

    assert data_from_step == first_step_data
    assert first_step == step_from_data
Ejemplo n.º 4
0
def get_test_script():
    sc = Script()
    sc.set_serialized_steps(TEST_STEP_DATA)
    return sc
Ejemplo n.º 5
0
def get_test_script():
    sc = Script()
    sc.set_serialized_steps(TEST_STEP_DATA)
    return sc
Ejemplo n.º 6
0
def test_run():
    event = get_initialized_test_event()
    step = Step(actions=[
        AddOrderLogEntry({
            "order": {
                "variable": "order"
            },
            "message": {
                "constant": "It Works."
            },
            "message_identifier": {
                "constant": "test_run"
            },
        })
    ],
                next=StepNext.STOP)
    script = Script(event_identifier=event.identifier, name="Test Script")
    script.set_steps([step])
    script.save()
    event.run()
    # The script is disabled by default, of course it won't run
    assert not event.variable_values["order"].log_entries.filter(
        identifier="test_run").exists()

    # Let's try that again.
    script.enabled = True
    script.save()
    event.run()
    assert event.variable_values["order"].log_entries.filter(
        identifier="test_run").exists()
    script.delete()