コード例 #1
0
def test_message_hash_no_change(client):
    component_id = shortuuid.uuid()[:8]
    component = FakeComponent(
        component_id=component_id,
        component_name="tests.views.fake_components.FakeComponent",
    )
    rendered_content = component.render()
    hash = generate_checksum(rendered_content)

    data = {"method_count": 0}
    response = post_and_get_response(
        client,
        url="/message/tests.views.fake_components.FakeComponent",
        data=data,
        action_queue=[{
            "payload": {
                "name": "test_method_kwargs(count=0)"
            },
            "type": "callMethod",
        }],
        component_id=component_id,
        hash=hash,
    )

    assert response.status_code == 304
コード例 #2
0
def test_message_hash_no_change_but_return_redirect(client):
    component_id = shortuuid.uuid()[:8]
    component = FakeComponent(
        component_id=component_id,
        component_name="tests.views.fake_components.FakeComponent",
    )
    rendered_content = component.render()
    hash = generate_checksum(rendered_content)

    data = {"method_count": 0}
    response = post_and_get_response(
        client,
        url="/message/tests.views.fake_components.FakeComponent",
        data=data,
        action_queue=[{
            "payload": {
                "name": "test_redirect"
            },
            "type": "callMethod",
        }],
        component_id=component_id,
        hash=hash,
    )

    # check that the response is JSON and not a 304
    assert isinstance(response, dict)
    assert response["return"]["value"]
コード例 #3
0
def test_get_property_value(client):
    component = FakeComponent(component_name="test", component_id="asdf")

    component.check = False
    check_value = _get_property_value(component, "check")
    assert check_value is False

    component.check = True
    check_value = _get_property_value(component, "check")

    assert check_value is True